(status: number, error: string)
| 120 | ) |
| 121 | |
| 122 | function jsonError(status: number, error: string): Response { |
| 123 | return new Response(JSON.stringify({ error }), { |
| 124 | status, |
| 125 | headers: { 'content-type': 'application/json' }, |
| 126 | }) |
| 127 | } |
| 128 | |
| 129 | /** |
| 130 | * Request middleware: parse + validate the body once and hand the typed result |