CartoDB-SQL-API/lib/api/middlewares/connection-params.js

22 lines
678 B
JavaScript
Raw Normal View History

2018-10-24 21:42:33 +08:00
'use strict';
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) {
req.profiler.done('getConnectionParams');
2019-12-24 01:19:08 +08:00
if (err) {
return next(err);
}
2019-12-24 01:19:08 +08:00
res.locals.userDbParams = userDbParams;
res.locals.authDbParams = authDbParams;
2019-12-24 01:19:08 +08:00
next();
});
};
};