From 9a6d5350e7d0fac0d5bc9f1f98877ad434b58e05 Mon Sep 17 00:00:00 2001 From: Nelson Martell Date: Tue, 7 Nov 2023 01:30:08 -0500 Subject: [PATCH 1/3] fix(json-api-express): make sure response status is a number Regardless of Error instance has `status` property as string, convert it to number for `res.status()`. Fixes #369 --- src/middlewares/json-api-express.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewares/json-api-express.ts b/src/middlewares/json-api-express.ts index 01a9b89..83eb894 100644 --- a/src/middlewares/json-api-express.ts +++ b/src/middlewares/json-api-express.ts @@ -51,7 +51,7 @@ export default function jsonApiExpress( try { await authenticate(appInstance, req); } catch (error) { - res.status(error.status).json(convertErrorToHttpResponse(error)); + res.status(+error.status).json(convertErrorToHttpResponse(error)); return next(); } From 555aac9c626bfe2dc44e14ef0cdd6c4ce7e1e2b1 Mon Sep 17 00:00:00 2001 From: Joel Alejandro Villarreal Bertoldi Date: Tue, 12 Dec 2023 18:10:06 -0300 Subject: [PATCH 2/3] Update src/middlewares/json-api-express.ts --- src/middlewares/json-api-express.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewares/json-api-express.ts b/src/middlewares/json-api-express.ts index 83eb894..fccdae8 100644 --- a/src/middlewares/json-api-express.ts +++ b/src/middlewares/json-api-express.ts @@ -51,7 +51,7 @@ export default function jsonApiExpress( try { await authenticate(appInstance, req); } catch (error) { - res.status(+error.status).json(convertErrorToHttpResponse(error)); + res.status(Number(error.status)).json(convertErrorToHttpResponse(error)); return next(); } From f4f9e4861dd6409c9e139355fb8d8dea9414de6f Mon Sep 17 00:00:00 2001 From: Joel Alejandro Villarreal Bertoldi Date: Tue, 12 Dec 2023 18:24:28 -0300 Subject: [PATCH 3/3] Update json-api-express.ts --- src/middlewares/json-api-express.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewares/json-api-express.ts b/src/middlewares/json-api-express.ts index fccdae8..83eb894 100644 --- a/src/middlewares/json-api-express.ts +++ b/src/middlewares/json-api-express.ts @@ -51,7 +51,7 @@ export default function jsonApiExpress( try { await authenticate(appInstance, req); } catch (error) { - res.status(Number(error.status)).json(convertErrorToHttpResponse(error)); + res.status(+error.status).json(convertErrorToHttpResponse(error)); return next(); }