UNPKG

1 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const execution_context_host_1 = require("../helpers/execution-context-host");
4class 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}
28exports.RouterProxy = RouterProxy;