burger-api
Version:
<p align="center"> <img src="https://github.com/user-attachments/assets/0d9b376e-1d89-479a-aa7f-e7ee3c6b2342" alt="BurgerAPI logo"/> </p>
18 lines (17 loc) • 874 B
TypeScript
/**
* Generates an HTTP error response based on the request's "Accept" header.
*
* If the "Accept" header includes "text/html" and debugging is enabled, it returns
* an HTML response with the error message and stack trace.
*
* If the "Accept" header includes "application/json" or debugging is enabled, it
* returns a JSON response with the error message and optionally the stack trace.
*
* Otherwise, it returns a plain text response indicating an internal server error.
*
* @param error - The error object or message to include in the response.
* @param req - The incoming HTTP request object.
* @param debug - A boolean indicating whether debugging information should be included.
* @returns A Response object with the appropriate error details and status code.
*/
export declare function errorResponse(error: any, req: Request, debug: boolean): Response;