Spaces:
Paused
Paused
Download packages/server/src/utils/responses.ts from f4b404/aiostreams: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/spaces/f4b404/aiostreams/resolve/main/packages/server/src/utils/responses.ts
- Command line
-
hf download hf://spaces/f4b404/aiostreams/packages/server/src/utils/responses.ts
-
curl -L -o responses.ts https://huggingface.co/spaces/f4b404/aiostreams/resolve/main/packages/server/src/utils/responses.ts
703 Bytes
| import { createLogger } from '@aiostreams/core'; | |
| import { Request } from 'express'; | |
| const logger = createLogger('server'); | |
| type ApiResponseOptions = { | |
| success: boolean; | |
| detail?: string; | |
| data?: any; | |
| error?: { | |
| code: string; | |
| message: string; | |
| issues?: any; | |
| }; | |
| }; | |
| export type ApiResponse<T> = { | |
| success: boolean; | |
| detail: string | null; | |
| data: T | null; | |
| error: { | |
| code: string; | |
| message: string; | |
| issues?: any; | |
| } | null; | |
| }; | |
| export function createResponse<T>(options: ApiResponseOptions): ApiResponse<T> { | |
| const { success, detail, data, error } = options; | |
| return { | |
| success, | |
| detail: detail || null, | |
| data: data || null, | |
| error: error || null, | |
| }; | |
| } | |