remove thenify use - no longer required

This commit is contained in:
Ray Bellis 2019-01-31 14:48:22 +00:00
parent ccb49dcdc1
commit b1c5024bcf
4 changed files with 20 additions and 23 deletions

View file

@ -21,7 +21,6 @@
var db = require("./DB"); var db = require("./DB");
var customError = require("../utils/customError"); var customError = require("../utils/customError");
var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString; var randomString = require('ep_etherpad-lite/static/js/pad_utils').randomString;
const thenify = require("thenify").withCallback;
exports.getColorPalette = function() { exports.getColorPalette = function() {
return [ return [

View file

@ -22,11 +22,10 @@
var ueberDB = require("ueberdb2"); var ueberDB = require("ueberdb2");
var settings = require("../utils/Settings"); var settings = require("../utils/Settings");
var log4js = require('log4js'); var log4js = require('log4js');
const thenify = require("thenify").withCallback;
const util = require("util"); const util = require("util");
// set database settings // set database settings
var db = new ueberDB.database(settings.dbType, settings.dbSettings, null, log4js.getLogger("ueberDB")); let db = new ueberDB.database(settings.dbType, settings.dbSettings, null, log4js.getLogger("ueberDB"));
/** /**
* The UeberDB Object that provides the database functions * The UeberDB Object that provides the database functions
@ -37,24 +36,25 @@ exports.db = null;
* Initalizes the database with the settings provided by the settings module * Initalizes the database with the settings provided by the settings module
* @param {Function} callback * @param {Function} callback
*/ */
exports.init = thenify(function (callback) { exports.init = function() {
// initalize the database async // initalize the database async
db.init(function(err) { return new Promise((resolve, reject) => {
if (err) { db.init(function(err) {
// there was an error while initializing the database, output it and stop if (err) {
console.error("ERROR: Problem while initalizing the database"); // there was an error while initializing the database, output it and stop
console.error(err.stack ? err.stack : err); console.error("ERROR: Problem while initalizing the database");
process.exit(1); console.error(err.stack ? err.stack : err);
} else { process.exit(1);
// everything ok } else {
exports.db = db; // everything ok, set up Promise-based methods
['get', 'set', 'findKeys', 'getSub', 'setSub', 'remove', 'doShutdown'].forEach(fn => {
exports[fn] = util.promisify(db[fn].bind(db));
});
// set up Promise-based methods // exposed for those callers that need the underlying raw API
['get', 'set', 'findKeys', 'getSub', 'setSub', 'remove', 'doShutdown'].forEach(fn => { exports.db = db;
exports[fn] = util.promisify(db[fn].bind(db)); resolve();
}); }
});
callback(null);
}
}); });
}); }

View file

@ -25,7 +25,6 @@ var sessionManager = require("./SessionManager");
var settings = require("../utils/Settings"); var settings = require("../utils/Settings");
var log4js = require('log4js'); var log4js = require('log4js');
var authLogger = log4js.getLogger("auth"); var authLogger = log4js.getLogger("auth");
const thenify = require("thenify").withCallback;
/** /**
* This function controlls the access to a pad, it checks if the user can access a pad. * This function controlls the access to a pad, it checks if the user can access a pad.

View file

@ -58,7 +58,6 @@
"slide": "1.1.6", "slide": "1.1.6",
"socket.io": "2.1.1", "socket.io": "2.1.1",
"swagger-node-express": "2.1.3", "swagger-node-express": "2.1.3",
"thenify": "^3.3.0",
"tinycon": "0.0.1", "tinycon": "0.0.1",
"ueberdb2": "0.4.0", "ueberdb2": "0.4.0",
"uglify-js": "2.6.2", "uglify-js": "2.6.2",