UNPKG

@mondaydotcomorg/node-execution-context

Version:

Persistent execution context allowing you to get/set the context anywhere implemented using async hooks. Can be used to create request level execution context, a stack trace that persists through async resources, or anything else you need to survive the e

30 lines (26 loc) 762 B
"use strict"; const asyncHooks = require("async_hooks"); const { init, destroy } = require("./async-hooks-callbacks"); const { getExecutionContext, getExecutionTrace, getExecutionData } = require("./execution-context-services/get-context-services"); const { setExecutionContext, updateExecutionContext } = require("./execution-context-services/set-context-services"); const { createExecutionContext } = require("./execution-context-services/create-context-service"); global.executionContextMap = new Map(); const asyncHook = asyncHooks.createHook({ init, destroy }); asyncHook.enable(); module.exports = { getExecutionContext, getExecutionTrace, getExecutionData, createExecutionContext, setExecutionContext, updateExecutionContext };