( res: http.ServerResponse, status: number, body: string, options?: ErrorResponseOptions, )
| 139 | } |
| 140 | |
| 141 | export function writeErrorResponse( |
| 142 | res: http.ServerResponse, |
| 143 | status: number, |
| 144 | body: string, |
| 145 | options?: ErrorResponseOptions, |
| 146 | ): void { |
| 147 | const headers: Record<string, string> = { "Content-Type": "application/json" }; |
| 148 | if (status === 429) { |
| 149 | headers["Retry-After"] = String(options?.retryAfter ?? 1); |
| 150 | Object.assign(headers, RATE_LIMIT_HEADERS); |
| 151 | } |
| 152 | res.writeHead(status, headers); |
| 153 | res.end(body); |
| 154 | } |
no test coverage detected
searching dependent graphs…