Change signature of req2params to follow express' middleware pattern

This commit is contained in:
Daniel García Aubert 2017-09-21 11:54:37 +02:00
parent daeae5d95c
commit 3b9c561cee

View File

@ -35,7 +35,7 @@ module.exports = BaseController;
* @param req - standard express request obj. Should have host & table
* @param callback
*/
BaseController.prototype.req2params = function(req, callback){
BaseController.prototype.req2params = function(req, res, next) {
var self = this;
if ( req.query.lzma ) {
@ -60,7 +60,7 @@ BaseController.prototype.req2params = function(req, callback){
self.req2params(req, callback);
} catch (err) {
req.profiler.done('req2params');
callback(new Error('Error parsing lzma as JSON: ' + err));
next(new Error('Error parsing lzma as JSON: ' + err));
}
}
);
@ -96,7 +96,7 @@ BaseController.prototype.req2params = function(req, callback){
);
err.http_status = 403;
req.profiler.done('req2params');
callback(err);
next(err);
return;
}
if ( tksplit.length > 1 ) {
@ -137,7 +137,7 @@ BaseController.prototype.req2params = function(req, callback){
function finishSetup(err) {
if ( err ) {
req.profiler.done('req2params');
return callback(err, req);
return next(err, req);
}
// Add default database connection parameters
@ -155,7 +155,7 @@ BaseController.prototype.req2params = function(req, callback){
_.defaults(req.locals, req.params);
req.profiler.done('req2params');
callback(null, req);
next(null, req);
}
);
};