Nicer logging of API requests

This commit is contained in:
Marshall Polaris 2022-07-17 20:50:13 -07:00
parent af3779b8be
commit e6a0ae10fa

View File

@ -123,7 +123,7 @@ export const newEndpoint = (endpointOpts: EndpointOptions, fn: Handler) => {
return {
opts,
handler: async (req: Request, res: Response) => {
log('Request processing started.')
log(`${req.method} ${req.url} ${JSON.stringify(req.body)}`)
try {
if (opts.method !== req.method) {
throw new APIError(405, `This endpoint supports only ${opts.method}.`)