Cleaned up up the middlewares

ref #11
This commit is contained in:
Nicolai Ort 2020-12-05 19:14:04 +01:00
parent f58a715c45
commit 1fb09e577c
1 changed files with 5 additions and 11 deletions

View File

@ -1,20 +1,14 @@
import {
Middleware,
ExpressErrorMiddlewareInterface
} from "routing-controllers";
import { ExpressErrorMiddlewareInterface, Middleware } from "routing-controllers";
/**
* Our Error handling middlware that returns our custom httperrors to the user
*/
@Middleware({ type: "after" })
export class ErrorHandler implements ExpressErrorMiddlewareInterface {
public error(
error: any,
request: any,
response: any,
next: (err: any) => any
) {
public error(error: any, request: any, response: any, next: (err: any) => any) {
if (response.headersSent) {
return;
}
response.json(error);
}
}