Spaces:
Sleeping
Sleeping
Download src/utils/response.ts from Anoderb/Tokiva-backend-Node: direct link, hf CLI and curl.
- Browser
- Download file 528 Bytes
-
https://huggingface.co/spaces/Anoderb/Tokiva-backend-Node/resolve/main/src/utils/response.ts
- Command line
-
hf download hf://spaces/Anoderb/Tokiva-backend-Node/src/utils/response.ts
-
curl -L -o response.ts https://huggingface.co/spaces/Anoderb/Tokiva-backend-Node/resolve/main/src/utils/response.ts
528 Bytes
| import { Response } from 'express'; | |
| export const sukses = ( | |
| res: Response, | |
| data: any = null, | |
| pesan: string = 'Berhasil', | |
| meta: any = null, | |
| statusCode = 200 | |
| ) => { | |
| return res.status(statusCode).json({ | |
| sukses: true, | |
| data, | |
| pesan, | |
| meta, | |
| }); | |
| }; | |
| export const gagal = ( | |
| res: Response, | |
| statusCode: number, | |
| pesan: string, | |
| error: string | null = null, | |
| detail: any = null | |
| ) => { | |
| return res.status(statusCode).json({ | |
| sukses: false, | |
| pesan, | |
| error, | |
| detail: detail ?? pesan, | |
| }); | |
| }; | |