Spaces:
Sleeping
Sleeping
Download backend/src/utils/apiResponse.ts from moustafa7/protofolio: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/utils/apiResponse.ts
- Command line
-
hf download hf://spaces/moustafa7/protofolio/backend/src/utils/apiResponse.ts
-
curl -L -o apiResponse.ts https://huggingface.co/spaces/moustafa7/protofolio/resolve/main/backend/src/utils/apiResponse.ts
703 Bytes
| import { Response } from "express"; | |
| export class ApiResponse { | |
| static success(res: Response, data: any, message = "Success", statusCode = 200) { | |
| return res.status(statusCode).json({ | |
| success: true, | |
| data, | |
| message, | |
| }); | |
| } | |
| static error(res: Response, message = "Error", statusCode = 500) { | |
| return res.status(statusCode).json({ | |
| success: false, | |
| message, | |
| }); | |
| } | |
| static paginated(res: Response, data: any[], total: number, page: number, limit: number) { | |
| return res.status(200).json({ | |
| success: true, | |
| data, | |
| pagination: { | |
| total, | |
| page, | |
| limit, | |
| totalPages: Math.ceil(total / limit), | |
| }, | |
| }); | |
| } | |
| } | |