UNPKG

1.03 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.RouterProxy = void 0;
4const execution_context_host_1 = require("../helpers/execution-context-host");
5class RouterProxy {
6 createProxy(targetCallback, exceptionsHandler) {
7 return async (req, res, next) => {
8 try {
9 await targetCallback(req, res, next);
10 }
11 catch (e) {
12 const host = new execution_context_host_1.ExecutionContextHost([req, res, next]);
13 exceptionsHandler.next(e, host);
14 }
15 };
16 }
17 createExceptionLayerProxy(targetCallback, exceptionsHandler) {
18 return async (err, req, res, next) => {
19 try {
20 await targetCallback(err, req, res, next);
21 }
22 catch (e) {
23 const host = new execution_context_host_1.ExecutionContextHost([req, res, next]);
24 exceptionsHandler.next(e, host);
25 }
26 };
27 }
28}
29exports.RouterProxy = RouterProxy;