From a45d836afe91d29e699058fa918c37577fc6d55a Mon Sep 17 00:00:00 2001 From: andrzej Date: Wed, 29 May 2024 12:07:17 +0200 Subject: [PATCH] add parameter to error handler turns out express needs the correct number of params, so 'unused' warnings should be ignored j --- dist/index.mjs | 2 +- index.mts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/index.mjs b/dist/index.mjs index f556717..343a9f2 100644 --- a/dist/index.mjs +++ b/dist/index.mjs @@ -14,7 +14,7 @@ app.use(bodyParser.urlencoded({ extended: false })); app.use("/", routes); app.use('/user', passport.authenticate('jwt', { session: false }), secureRoute); // Handle errors. -app.use(function (err, req, res) { +app.use(function (err, req, res, next) { res.status(err.status || 500); res.json({ error: err }); }); diff --git a/index.mts b/index.mts index 2e7f89b..9f72d71 100644 --- a/index.mts +++ b/index.mts @@ -19,7 +19,7 @@ app.use("/", routes) app.use('/user', passport.authenticate('jwt', { session: false }), secureRoute); // Handle errors. -app.use(function(err: any, req, res: any) { +app.use(function(err: any, req: any, res: any, next: any) { res.status(err.status || 500); res.json({ error: err }); });