Nicer logging of API requests
This commit is contained in:
parent
af3779b8be
commit
e6a0ae10fa
|
@ -123,7 +123,7 @@ export const newEndpoint = (endpointOpts: EndpointOptions, fn: Handler) => {
|
||||||
return {
|
return {
|
||||||
opts,
|
opts,
|
||||||
handler: async (req: Request, res: Response) => {
|
handler: async (req: Request, res: Response) => {
|
||||||
log('Request processing started.')
|
log(`${req.method} ${req.url} ${JSON.stringify(req.body)}`)
|
||||||
try {
|
try {
|
||||||
if (opts.method !== req.method) {
|
if (opts.method !== req.method) {
|
||||||
throw new APIError(405, `This endpoint supports only ${opts.method}.`)
|
throw new APIError(405, `This endpoint supports only ${opts.method}.`)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user