fix middleware stuff
This commit is contained in:
@@ -47,12 +47,10 @@ app.use(express.static(path.join(__dirname, "public"), {
|
||||
app.use("/api/docs", swaggerUi.serve, swaggerUi.setup(specs));
|
||||
app.use("/api", apiRouter);
|
||||
|
||||
app.use((req, res) => {
|
||||
res.status(404).send("Not Found");
|
||||
})
|
||||
|
||||
// has to be last
|
||||
app.use((_req, res, _next) => {
|
||||
app.use((_req, res, next) => {
|
||||
if (res.error == null) {
|
||||
return res.status(404).send("Not Found");
|
||||
} else {
|
||||
const err = res.error;
|
||||
if (err instanceof ApiError) {
|
||||
return res.status(err.status).json({ status: "error", error: err.message });
|
||||
@@ -60,6 +58,7 @@ app.use((_req, res, _next) => {
|
||||
|
||||
console.error(err);
|
||||
res.status(500).json({ status: "error", error: "Internal server error" });
|
||||
}
|
||||
})
|
||||
|
||||
const server = https.createServer({
|
||||
|
||||
Reference in New Issue
Block a user