Spaces:
Sleeping
Sleeping
Download src/libs/shared/api/ApiResponse.ts from fouadkhalid123/asd: direct link, hf CLI and curl.
- Browser
- Download file 470 Bytes
-
https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/libs/shared/api/ApiResponse.ts
- Command line
-
hf download hf://spaces/fouadkhalid123/asd/src/libs/shared/api/ApiResponse.ts
-
curl -L -o ApiResponse.ts https://huggingface.co/spaces/fouadkhalid123/asd/resolve/main/src/libs/shared/api/ApiResponse.ts
470 Bytes
| import { Response } from "express"; | |
| export class ApiResponse { | |
| static success<T>(res: Response, data: T, status = 200): void { | |
| res.status(status).json({ success: true, data }); | |
| } | |
| static accepted<T>(res: Response, data: T): void { | |
| this.success(res, data, 202); | |
| } | |
| static error(res: Response, status: number, code: string, message: string): void { | |
| res.status(status).json({ success: false, error: { code, message } }); | |
| } | |
| } |