thrilled-be-core
Version:
Core Express backend package with middleware, logging, security, and base application setup
62 lines • 2.08 kB
TypeScript
import { Response } from 'express';
export interface ApiSuccessResponse<T = unknown> {
success: true;
message: string;
data?: T;
meta?: Record<string, unknown>;
statusCode: number;
}
export interface ApiErrorResponse {
success: false;
message: string;
errors?: Array<Record<string, unknown>>;
statusCode: number;
requestId?: string;
}
export declare class ApiResponse {
/**
* Send success response
*/
static success<T>(res: Response, message?: string, data?: T, meta?: Record<string, unknown>): Response<ApiSuccessResponse<T>>;
/**
* Send created response
*/
static created<T>(res: Response, message?: string, data?: T): Response<ApiSuccessResponse<T>>;
/**
* Send no content response
*/
static noContent(res: Response): Response;
/**
* Send bad request error
*/
static badRequest(res: Response, message?: string, errors?: Array<Record<string, unknown>>): Response<ApiErrorResponse>;
/**
* Send unauthorized error
*/
static unauthorized(res: Response, message?: string): Response<ApiErrorResponse>;
/**
* Send forbidden error
*/
static forbidden(res: Response, message?: string): Response<ApiErrorResponse>;
/**
* Send not found error
*/
static notFound(res: Response, message?: string): Response<ApiErrorResponse>;
/**
* Send conflict error
*/
static conflict(res: Response, message?: string): Response<ApiErrorResponse>;
/**
* Send internal server error
*/
static serverError(res: Response, message?: string): Response<ApiErrorResponse>;
/**
* Send custom error response
*/
static error(res: Response, statusCode: number, message: string, errors?: Array<Record<string, unknown>>): Response<ApiErrorResponse>;
/**
* Send custom response (for backward compatibility)
*/
static custom(res: Response, statusCode: number, message: string, data?: unknown, meta?: Record<string, unknown>): Response;
}
//# sourceMappingURL=ApiResponse.d.ts.map