initial
This commit is contained in:
12
apps/backend/src/common/request-context/request-context.ts
Normal file
12
apps/backend/src/common/request-context/request-context.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
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';
|
||||
}
|
||||
Reference in New Issue
Block a user