mirror of
https://github.com/detleph/server.git
synced 2026-09-04 08:36:06 +02:00
Fix json parser return stack trace see Issue #24;
This commit is contained in:
+12
-1
@@ -1,4 +1,4 @@
|
||||
import express from "express";
|
||||
import express, { ErrorRequestHandler, NextFunction, Request, Response } from "express";
|
||||
import prisma from "./lib/prisma";
|
||||
import eventRouter from "./Routes/event.routes";
|
||||
import adminAuthRouter from "./Routes/admin_auth.routes";
|
||||
@@ -27,6 +27,17 @@ async function main() {
|
||||
app.use(express.urlencoded({ extended: true }));
|
||||
app.use(express.json());
|
||||
|
||||
app.use((err: any, req: Request, res: Response, next: NextFunction) => {
|
||||
if (err) {
|
||||
res.status(400).send({
|
||||
type: "error",
|
||||
payload: "The body of your request did not contain valid data"
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
});
|
||||
|
||||
// Admin authentication endpoints
|
||||
app.use("/api/authentication", adminAuthRouter);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user