Use req/res logger instead of the one bound to global object

This commit is contained in:
Daniel García Aubert
2020-06-02 12:31:18 +02:00
parent ffe19827fd
commit b60116410a
5 changed files with 34 additions and 32 deletions
+2
View File
@@ -152,6 +152,7 @@ function prepareAdapterMapConfig (mapConfigAdapter) {
return function prepareAdapterMapConfigMiddleware (req, res, next) {
const requestMapConfig = req.body;
const { logger } = res.locals;
const { user, api_key: apiKey } = res.locals;
const { dbuser, dbname, dbpassword, dbhost, dbport } = res.locals;
const params = Object.assign({ dbuser, dbname, dbpassword, dbhost, dbport }, req.query);
@@ -159,6 +160,7 @@ function prepareAdapterMapConfig (mapConfigAdapter) {
const context = {
analysisConfiguration: {
user,
logger,
db: {
host: dbhost,
port: dbport,
+3 -2
View File
@@ -3,9 +3,10 @@
const CdbRequest = require('../../models/cdb-request');
module.exports = function user (metadataBackend) {
const cdbRequest = new CdbRequest();
return function userMiddleware (req, res, next) {
const { logger } = res.locals;
const cdbRequest = new CdbRequest({ logger });
res.locals.user = getUserNameFromRequest(req, cdbRequest);
metadataBackend.getUserId(res.locals.user, (err, userId) => {