Files
boilerplate/apps/backend/src/common/request-context/request-context.ts
Bastian Wagner 543e8273a7 initial
2026-07-16 09:49:22 +02:00

13 lines
321 B
TypeScript

import { AsyncLocalStorage } from 'node:async_hooks';
export interface RequestContext {
requestId: string;
userId?: string;
}
export const requestContextStorage = new AsyncLocalStorage<RequestContext>();
export function getRequestId(): string {
return requestContextStorage.getStore()?.requestId ?? 'unknown';
}