Session
Custom global state that persists throughout a request's life cycle
yarn add q3-core-sessionExample
const { get, intercept } = require('q3-core-session');
const { getPriceIn } = require('../utils');
/**
* This function executes inside express.
* It is the last call before the controller.
*/
intercept('CURRENCY', (req) => {
return req.headers['x-display'];
});
/**
* This function queries a key set in the intercept callback.
*/
exports.convertPriceToLocalCurrency = async () => {
const currency = get('CURRENCY');
return getPriceIn(currency);
};
Last updated