From e46bd02f8c4836181b291e57b753f1c80b8fad5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20FAMIBELLE-PRONZOLA?= Date: Sat, 19 Feb 2022 21:43:12 +0400 Subject: [PATCH] Create handler for api requests --- lib/utils/w.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 lib/utils/w.js diff --git a/lib/utils/w.js b/lib/utils/w.js new file mode 100644 index 0000000..b79e6c1 --- /dev/null +++ b/lib/utils/w.js @@ -0,0 +1,11 @@ +function w(handler) { + return async (request, response, next) => { + try { + await handler(request, response, next) + } catch (error) { + next(error) + } + } +} + +module.exports = w