UNPKG

ts-express-kit

Version:

A TypeScript starter kit for building Express applications with best practices.

27 lines (23 loc) 485 B
import { Response } from 'express'; type TMeta = { limit: number; page: number; total: number; totalPage: number; }; type TResponse<T> = { statusCode: number; success: boolean; message?: string; meta?: TMeta; data: T; }; const sendResponse = <T>(res: Response, data: TResponse<T>) => { res.status(data?.statusCode).json({ success: data.success, message: data.message, meta: data.meta, data: data.data }); }; export default sendResponse;