CartoDB-SQL-API/app/middlewares/connection-params.js

22 lines
681 B
JavaScript
Raw Normal View History

module.exports = function connectionParams (userDatabaseService) {
return function connectionParamsMiddleware (req, res, next) {
const { user, api_key: apikeyToken, authorizationLevel } = res.locals;
userDatabaseService.getConnectionParams(user, apikeyToken, authorizationLevel,
2018-02-22 22:59:13 +08:00
function (err, userDbParams, authDbParams) {
if (req.profiler) {
2018-02-22 19:23:37 +08:00
req.profiler.done('getConnectionParams');
}
if (err) {
return next(err);
}
res.locals.userDbParams = userDbParams;
res.locals.authDbParams = authDbParams;
next();
});
};
};