fix: Server error when invalid JSON passed to API endpoint

Fix is to ensure that the errorHandling middleware is mounted before the body parser so that it can catch and return an error response
This commit is contained in:
Tom Moor
2020-12-20 12:08:47 -08:00
parent 47ce8afcc5
commit 4684b3a3f3

View File

@@ -31,13 +31,13 @@ const api = new Koa();
const router = new Router();
// middlewares
api.use(errorHandling());
api.use(
bodyParser({
multipart: true,
formidable: { maxFieldsSize: 10 * 1024 * 1024 },
})
);
api.use(errorHandling());
api.use(methodOverride());
api.use(validation());
api.use(apiWrapper());