From 28e04d4e28534f987be335064e3e607bcd7edf2b Mon Sep 17 00:00:00 2001 From: b1ek Date: Mon, 11 Nov 2024 21:33:58 +1000 Subject: [PATCH] properly handle async errors in express --- back/package.json | 1 + back/src/index.ts | 1 + back/yarn.lock | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/back/package.json b/back/package.json index 5fcf819..6db3353 100644 --- a/back/package.json +++ b/back/package.json @@ -21,6 +21,7 @@ "connect-typeorm": "^2.0.0", "dotenv": "^16.4.5", "express": "^4.21.1", + "express-async-errors": "^3.1.1", "express-session": "^1.18.1", "pg": "^8.13.1", "reflect-metadata": "^0.2.2", diff --git a/back/src/index.ts b/back/src/index.ts index 751de9e..95d7730 100644 --- a/back/src/index.ts +++ b/back/src/index.ts @@ -7,6 +7,7 @@ import routes from './routes.js'; import dataSourceRepo from './typeorm/data-source.repo.js'; import { Session } from './typeorm/entity/Session.entity.js'; +import 'express-async-errors'; import './env.js'; const listen_host = process.env.LISTEN_HOST ?? '0.0.0.0'; diff --git a/back/yarn.lock b/back/yarn.lock index c714211..fd59967 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -570,6 +570,11 @@ etag@~1.8.1: resolved "https://registry.yarnpkg.com/etag/-/etag-1.8.1.tgz#41ae2eeb65efa62268aebfea83ac7d79299b0887" integrity sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg== +express-async-errors@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/express-async-errors/-/express-async-errors-3.1.1.tgz#6053236d61d21ddef4892d6bd1d736889fc9da41" + integrity sha512-h6aK1da4tpqWSbyCa3FxB/V6Ehd4EEB15zyQq9qe75OZBp0krinNKuH4rAY+S/U/2I36vdLAUFSjQJ+TFmODng== + express-session@^1.15.6, express-session@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/express-session/-/express-session-1.18.1.tgz#88d0bbd41878882840f24ec6227493fcb167e8d5"