UNPKG

@benie/lambda-lib

Version:

Builders and tools for creating AWS Lambda function handlers that provides automation for things such as logging, instrumentation and parameters propagation

20 lines (14 loc) 433 B
exports.clearAll = () => global.CONTEXT = undefined; exports.replaceAllWith = ctx => global.CONTEXT = ctx; exports.set = (key, value) => { if (!key.startsWith('x-correlation-')) { key = 'x-correlation-' + key; } if (!global.CONTEXT) { global.CONTEXT = {}; } global.CONTEXT[key] = value; }; exports.get = () => { return (global.CONTEXT ? Object.assign({}, global.CONTEXT) : undefined); };