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