/** * Standardized API Response Utilities * Provides consistent response format across all applications */ import { Response } from "express"; export interface ApiResponse { success: boolean; data?: T; error?: string; message?: string; timestamp?: string; metadata?: Record; } export interface ApiErrorResponse extends ApiResponse { success: false; error: string; code?: string; details?: any; stack?: string; } export interface ApiSuccessResponse extends ApiResponse { success: true; data: T; } /** * Send a successful response */ export declare function sendSuccess(res: Response, data: T, message?: string, statusCode?: number): Response>; /** * Send an error response */ export declare function sendError(res: Response, error: string | Error, statusCode?: number, details?: any): Response; /** * Send a validation error response */ export declare function sendValidationError(res: Response, errors: any, message?: string): Response; /** * Send a not found response */ export declare function sendNotFound(res: Response, resource?: string): Response; /** * Send an unauthorized response */ export declare function sendUnauthorized(res: Response, message?: string): Response; /** * Send a forbidden response */ export declare function sendForbidden(res: Response, message?: string): Response; /** * Send a bad request response */ export declare function sendBadRequest(res: Response, message?: string): Response; /** * Send a created response */ export declare function sendCreated(res: Response, data: T, message?: string): Response>; /** * Send a no content response */ export declare function sendNoContent(res: Response): Response; /** * Wrap async route handlers to catch errors */ export declare function asyncHandler(fn: (req: any, res: any, next: any) => any): (req: any, res: any, next: any) => void; /** * Standard error handler middleware */ export declare function apiErrorHandler(err: any, _req: any, res: any, next: any): any; //# sourceMappingURL=apiResponse.d.ts.map