PRININIT / lib /src /context.js
Rachit-Tw's picture
Upload 183 files
272a04f verified
Raw
History Blame Contribute Delete
904 Bytes
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSafeRepo = exports.getSafeOctokit = exports.getCurrentContext = exports.als = void 0;
const async_hooks_1 = require("async_hooks");
// Global context storage for current execution thread
exports.als = new async_hooks_1.AsyncLocalStorage();
/**
* Access the current execution context safely from anywhere in the codebase.
*/
const getCurrentContext = () => {
return exports.als.getStore();
};
exports.getCurrentContext = getCurrentContext;
/**
* Helper to get octokit from current context
*/
const getSafeOctokit = () => {
return exports.als.getStore()?.octokit;
};
exports.getSafeOctokit = getSafeOctokit;
/**
* Helper to get repo info from current context
*/
const getSafeRepo = () => {
return exports.als.getStore()?.repo;
};
exports.getSafeRepo = getSafeRepo;
//# sourceMappingURL=context.js.map