@zakyyudha/http-context-middleware
Version:
HTTP context middleware using Node.js AsyncLocalStorage
23 lines (22 loc) • 628 B
TypeScript
export interface IHttpContext {
requestId: string;
startTime: number;
route?: string;
method?: string;
requestDuration?: number;
req?: any;
res?: any;
[key: string]: any;
}
declare class HttpContext {
private static instance;
private constructor();
static getInstance(): HttpContext;
getContext(): IHttpContext | null;
get<T = any>(key: string): T | undefined;
set<T = any>(key: string, value: T): boolean;
runWithContext<T>(context: IHttpContext, callback: () => T): T;
generateRequestId(): string;
}
declare const _default: HttpContext;
export default _default;