error handler + login

This commit is contained in:
2022-10-15 22:04:27 +02:00
parent b2024bf4aa
commit f6a7415884
15 changed files with 197 additions and 43 deletions

View File

@ -1,4 +1,4 @@
import { Request, RequestHandler } from 'express';
import { ErrorRequestHandler, Request, RequestHandler } from 'express';
import { randomUUID } from 'crypto';
export function getId(req: Request): string {
@ -11,3 +11,11 @@ export function BeforeEach(): RequestHandler {
next();
};
}
export function ErrorHandler(): ErrorRequestHandler {
return (error, req, res, next) => {
error.status
? res.status(error.status).send(error)
: res.status(500).send(error);
};
}