improve: log request body of unimplemented requests

This commit is contained in:
Sainan 2024-07-03 02:41:35 +02:00
parent 76bff65d92
commit 68cfc68755

View File

@ -3,6 +3,9 @@ import { /*NextFunction,*/ Request, Response } from "express";
const unknownEndpointHandler = (request: Request, response: Response) => { const unknownEndpointHandler = (request: Request, response: Response) => {
logger.error(`unknown endpoint ${request.method} ${request.path}`); logger.error(`unknown endpoint ${request.method} ${request.path}`);
if (request.body) {
logger.debug(`data provided to ${request.path}: ${String(request.body)}`);
}
response.status(404).json({ error: "endpoint was not found" }); response.status(404).json({ error: "endpoint was not found" });
}; };