UNPKG

@rollercoaster-dev/rd-logger

Version:

A neurodivergent-friendly logger for Rollercoaster.dev projects

33 lines (32 loc) 1.19 kB
export interface RequestStore { requestId: string; requestStartTime: number; } /** * Runs a function within an asynchronous request context. * Creates a new context with a unique request ID and start time. * * @param fn The function to execute within the context. * @param existingRequestId Optional request ID from headers (e.g., 'x-request-id') * @returns The return value of the executed function. */ export declare function runWithRequestContext<T>(fn: () => T, existingRequestId?: string | null): T; /** * Gets the current request context store. * Returns undefined if called outside a context created by runWithRequestContext. * * @returns The current request store or undefined. */ export declare function getRequestStore(): RequestStore | undefined; /** * Gets the current request ID. * * @returns The current request ID or 'unknown' if not in a request context. */ export declare function getCurrentRequestId(): string; /** * Gets the start time of the current request. * * @returns The request start timestamp (milliseconds since epoch) or the current time if not in a request context. */ export declare function getCurrentRequestStartTime(): number;