1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | class ExecutionContextHost {
|
4 | constructor(args, constructorRef = null, handler = null) {
|
5 | this.args = args;
|
6 | this.constructorRef = constructorRef;
|
7 | this.handler = handler;
|
8 | this.contextType = 'http';
|
9 | }
|
10 | setType(type) {
|
11 | type && (this.contextType = type);
|
12 | }
|
13 | getType() {
|
14 | return this.contextType;
|
15 | }
|
16 | getClass() {
|
17 | return this.constructorRef;
|
18 | }
|
19 | getHandler() {
|
20 | return this.handler;
|
21 | }
|
22 | getArgs() {
|
23 | return this.args;
|
24 | }
|
25 | getArgByIndex(index) {
|
26 | return this.args[index];
|
27 | }
|
28 | switchToRpc() {
|
29 | return Object.assign(this, {
|
30 | getData: () => this.getArgByIndex(0),
|
31 | getContext: () => this.getArgByIndex(1),
|
32 | });
|
33 | }
|
34 | switchToHttp() {
|
35 | return Object.assign(this, {
|
36 | getRequest: () => this.getArgByIndex(0),
|
37 | getResponse: () => this.getArgByIndex(1),
|
38 | getNext: () => this.getArgByIndex(2),
|
39 | });
|
40 | }
|
41 | switchToWs() {
|
42 | return Object.assign(this, {
|
43 | getClient: () => this.getArgByIndex(0),
|
44 | getData: () => this.getArgByIndex(1),
|
45 | });
|
46 | }
|
47 | }
|
48 | exports.ExecutionContextHost = ExecutionContextHost;
|