error-response-handler
Version:
Comprehensive error handling and response formatting for Node.js applications
21 lines (20 loc) • 548 B
TypeScript
import { StatusCodeKey, StatusCodeValue } from "./statusCodes";
export interface SuccessResponse<T> {
success: true;
message: string;
data?: T;
statusCode: number;
statusText: string;
timestamp: string;
}
export interface ErrorResponse {
success: false;
message: string;
error?: unknown;
statusCode: number;
statusText: string;
timestamp: string;
stack?: string;
}
export type AsyncFunction<T> = (...args: any[]) => Promise<T>;
export type StatusInput = number | StatusCodeKey | StatusCodeValue;