roads
Version:
An isomophic http framework
28 lines • 878 B
JavaScript
/**
* storeVals.ts
* Copyright(c) 2021 Aaron Hedges <aaron@dashron.com>
* MIT Licensed
*
* Exposes two functions on the context that allow you to store and retrieve values.
* You can of course apply values directly to the context, but this is useful
* to reduce polluting the context
*/
/**
* Exposes two functions on the context that allow you to store and retrieve values.
* You can of course apply values directly to the context, but this is useful
* to reduce polluting the context
*/
export const middleware = function (method, path, body, headers, next) {
const storedVals = {};
this.storeVal = (field, val) => {
storedVals[field] = val;
};
this.getVal = (field) => {
return storedVals[field];
};
this.getAllVals = () => {
return storedVals;
};
return next();
};
//# sourceMappingURL=storeVals.js.map