( code: string, message: string, status: number, details?: Record<string, unknown>, )
| 29 | * Use this for all error responses in API routes. |
| 30 | */ |
| 31 | export function apiError( |
| 32 | code: string, |
| 33 | message: string, |
| 34 | status: number, |
| 35 | details?: Record<string, unknown>, |
| 36 | ): Response { |
| 37 | const error: { code: string; message: string; details?: Record<string, unknown> } = { |
| 38 | code, |
| 39 | message, |
| 40 | }; |
| 41 | if (details !== undefined) error.details = details; |
| 42 | return Response.json({ error }, { status, headers: API_CACHE_HEADERS }); |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Create a standardized success response. |
no test coverage detected