Follow middleware pattern

This commit is contained in:
Daniel García Aubert 2018-03-01 18:09:49 +01:00
parent 2c762813ba
commit bd93e7dc7e
2 changed files with 30 additions and 28 deletions

View File

@ -9,7 +9,7 @@ module.exports = function prepareContextMiddleware(authApi, pgConnection) {
return [
locals(),
cleanUpQueryParams(),
layergroupToken,
layergroupToken(),
credentials(),
authorize(authApi),
dbConnSetup(pgConnection)

View File

@ -1,6 +1,7 @@
var LayergroupToken = require('../../models/layergroup-token');
module.exports = function layergroupTokenMiddleware(req, res, next) {
module.exports = function layergroupToken () {
return function layergroupTokenMiddleware(req, res, next) {
if (!res.locals.token) {
return next();
}
@ -30,3 +31,4 @@ module.exports = function layergroupTokenMiddleware(req, res, next) {
return next();
};
};