/** * API Route Wrapper * * Wraps Next.js API routes to automatically set up request context, * error handling, and logging. */ /** * API route handler function */ export type ApiHandler = (request: Request) => Promise; /** * Wrap an API route handler with request context, logging, and error handling * * Benefits: * - Automatic request ID generation and propagation * - Request context available via getRequestContext() * - Automatic error handling with proper status codes * - Request/response logging with timing * - All logs include request ID automatically * * @param handler - API route handler function * @returns Wrapped handler with request context * * @example * ```typescript * // app/api/users/route.ts * import { withRequestContext } from '@revealui/core/utils/api-wrapper' * // Uses standard Web API Request/Response * * export const GET = withRequestContext(async (request) => { * // Request ID automatically available in logs * logger.info('Fetching users') // Includes requestId automatically * * const users = await db.query.users.findMany() * return Response.json(users) * }) * ``` */ export declare function withRequestContext(handler: ApiHandler): ApiHandler; /** * Server action wrapper for request context * * Use this for Next.js Server Actions to enable request tracing * * @param action - Server action function * @returns Wrapped action with request context * * @example * ```typescript * 'use server' * * import { withServerActionContext } from '@revealui/core/utils/api-wrapper' * * export const createUser = withServerActionContext(async (data) => { * logger.info('Creating user') // Includes requestId * return await db.insert(users).values(data) * }) * ``` */ export declare function withServerActionContext(action: (...args: TArgs) => Promise): (...args: TArgs) => Promise; //# sourceMappingURL=api-wrapper.d.ts.map