@geniucode/common-utils
Version:
Common utils
28 lines • 1.02 kB
JavaScript
import { TErrors } from '@geniucode/terminator';
import { logi } from '../logger';
import { setContextDataOfHttpByObject } from '../context';
const logger = logi(__filename);
export const initHttpContext = (req, res, next) => {
try {
const projectName = req.headers['project-name'];
const authAction = req.headers['auth-action'];
const authExpire = req.headers['auth-expire'];
const authToken = req.headers['auth-token'];
const userType = req.headers['user-type'];
const data = {
projectName,
authAction,
authExpire,
userType,
authToken,
};
logger.info('+++++++Middlewate@initHttpContext | Before Setting http context data');
setContextDataOfHttpByObject(data);
}
catch (error) {
logger.error(error?.message);
throw new TErrors.ValidationError('Something went wrong @initHttpContext headers');
}
next();
};
//# sourceMappingURL=init-http-context.js.map