@tsed/common 6.122.3 → 6.124.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/jest.config.js CHANGED
@@ -8,7 +8,7 @@ module.exports = {
8
8
  statements: 92.13,
9
9
  branches: 76.27,
10
10
  functions: 88.36,
11
- lines: 92.34
11
+ lines: 92.29
12
12
  }
13
13
  }
14
14
  };
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PlatformContext = void 0;
4
4
  const di_1 = require("@tsed/di");
5
- const schema_1 = require("@tsed/schema");
6
5
  const PlatformApplication_1 = require("../services/PlatformApplication");
7
6
  const PlatformRequest_1 = require("../services/PlatformRequest");
8
7
  const PlatformResponse_1 = require("../services/PlatformResponse");
@@ -24,7 +23,10 @@ class PlatformContext extends di_1.DIContext {
24
23
  * The current @@PlatformRequest@@.
25
24
  */
26
25
  request;
27
- ignoreUrlPatterns = [];
26
+ /**
27
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
28
+ */
29
+ endpoint;
28
30
  #isDestroyed = false;
29
31
  constructor(options) {
30
32
  super(options);
@@ -34,20 +36,8 @@ class PlatformContext extends di_1.DIContext {
34
36
  this.request = new (options.RequestKlass || PlatformRequest_1.PlatformRequest)(this);
35
37
  this.request.request.$ctx = this;
36
38
  this.request.request.id = this.id;
37
- this.container.set(PlatformResponse_1.PlatformResponse, this.response);
38
- this.container.set(PlatformRequest_1.PlatformRequest, this.request);
39
- this.container.set(PlatformContext, this);
40
39
  this.response.setHeader("x-request-id", this.id);
41
40
  }
42
- /**
43
- * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
44
- */
45
- get endpoint() {
46
- return this.get(schema_1.EndpointMetadata);
47
- }
48
- set endpoint(endpoint) {
49
- this.set(schema_1.EndpointMetadata, endpoint);
50
- }
51
41
  get url() {
52
42
  return this.request.url;
53
43
  }
@@ -56,7 +46,7 @@ class PlatformContext extends di_1.DIContext {
56
46
  }
57
47
  async destroy() {
58
48
  await super.destroy();
59
- this.upgrade({
49
+ this.event = {
60
50
  response: {
61
51
  isDone: true,
62
52
  statusCode: this.statusCode
@@ -69,7 +59,7 @@ class PlatformContext extends di_1.DIContext {
69
59
  query: this.query,
70
60
  params: this.params
71
61
  }
72
- });
62
+ };
73
63
  this.response.destroy();
74
64
  this.request.destroy();
75
65
  this.#isDestroyed = true;
@@ -107,9 +97,6 @@ class PlatformContext extends di_1.DIContext {
107
97
  getApp() {
108
98
  return this.app.getApp();
109
99
  }
110
- upgrade(event) {
111
- this.event = event;
112
- }
113
100
  }
114
101
  exports.PlatformContext = PlatformContext;
115
102
  //# sourceMappingURL=PlatformContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AACrE,yCAA8C;AAG9C,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAc9D,MAAa,eACX,SAAQ,cAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IAEf,iBAAiB,GAAa,EAAE,CAAC;IACzC,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,mCAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,iCAAe,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,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB;SACK,CAAC,CAAC;QAEV,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF;AA/HD,0CA+HC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n\n private ignoreUrlPatterns: RegExp[] = [];\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n get endpoint(): EndpointMetadata {\n return this.get(EndpointMetadata);\n }\n\n set endpoint(endpoint: EndpointMetadata) {\n this.set(EndpointMetadata, endpoint);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.upgrade({\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any);\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n\n upgrade(event: IncomingEvent) {\n this.event = event;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqE;AAIrE,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAc9D,MAAa,eACX,SAAQ,cAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IACvB;;OAEG;IACH,QAAQ,CAAmB;IAE3B,YAAY,GAAY,KAAK,CAAC;IAE9B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,mCAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,iCAAe,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QAC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,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF;AAhHD,0CAgHC","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n endpoint: EndpointMetadata;\n\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.event = {\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any;\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
@@ -1,5 +1,4 @@
1
1
  import { DIContext } from "@tsed/di";
2
- import { EndpointMetadata } from "@tsed/schema";
3
2
  import { PlatformApplication } from "../services/PlatformApplication.js";
4
3
  import { PlatformRequest } from "../services/PlatformRequest.js";
5
4
  import { PlatformResponse } from "../services/PlatformResponse.js";
@@ -21,7 +20,10 @@ export class PlatformContext extends DIContext {
21
20
  * The current @@PlatformRequest@@.
22
21
  */
23
22
  request;
24
- ignoreUrlPatterns = [];
23
+ /**
24
+ * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
25
+ */
26
+ endpoint;
25
27
  #isDestroyed = false;
26
28
  constructor(options) {
27
29
  super(options);
@@ -31,20 +33,8 @@ export class PlatformContext extends DIContext {
31
33
  this.request = new (options.RequestKlass || PlatformRequest)(this);
32
34
  this.request.request.$ctx = this;
33
35
  this.request.request.id = this.id;
34
- this.container.set(PlatformResponse, this.response);
35
- this.container.set(PlatformRequest, this.request);
36
- this.container.set(PlatformContext, this);
37
36
  this.response.setHeader("x-request-id", this.id);
38
37
  }
39
- /**
40
- * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
41
- */
42
- get endpoint() {
43
- return this.get(EndpointMetadata);
44
- }
45
- set endpoint(endpoint) {
46
- this.set(EndpointMetadata, endpoint);
47
- }
48
38
  get url() {
49
39
  return this.request.url;
50
40
  }
@@ -53,7 +43,7 @@ export class PlatformContext extends DIContext {
53
43
  }
54
44
  async destroy() {
55
45
  await super.destroy();
56
- this.upgrade({
46
+ this.event = {
57
47
  response: {
58
48
  isDone: true,
59
49
  statusCode: this.statusCode
@@ -66,7 +56,7 @@ export class PlatformContext extends DIContext {
66
56
  query: this.query,
67
57
  params: this.params
68
58
  }
69
- });
59
+ };
70
60
  this.response.destroy();
71
61
  this.request.destroy();
72
62
  this.#isDestroyed = true;
@@ -104,8 +94,5 @@ export class PlatformContext extends DIContext {
104
94
  getApp() {
105
95
  return this.app.getApp();
106
96
  }
107
- upgrade(event) {
108
- this.event = event;
109
- }
110
97
  }
111
98
  //# sourceMappingURL=PlatformContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,cAAc,CAAC;AAG9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAc9D,MAAM,OAAO,eACX,SAAQ,SAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IAC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IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,KAAoB;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n\n private ignoreUrlPatterns: RegExp[] = [];\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n get endpoint(): EndpointMetadata {\n return this.get(EndpointMetadata);\n }\n\n set endpoint(endpoint: EndpointMetadata) {\n this.set(EndpointMetadata, endpoint);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.upgrade({\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any);\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n\n upgrade(event: IncomingEvent) {\n this.event = event;\n }\n}\n"]}
1
+ {"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AAIrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAc9D,MAAM,OAAO,eACX,SAAQ,SAAS;IAGV,KAAK,CAAgB;IAC5B;;OAEG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AC,MAAM;gBACnB,GAAG,EAAE,IAAI,CAAC,GAAG;gBACb,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB;SACK,CAAC;QAET,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,YAAY,CAAC;IACnF,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse>\n extends DIContext\n implements ContextMethods\n{\n public event: IncomingEvent;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The error caught by the current handler\n */\n public error?: unknown;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n endpoint: EndpointMetadata;\n\n #isDestroyed: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n this.event = {\n response: {\n isDone: true,\n statusCode: this.statusCode\n },\n request: {\n method: this.method,\n url: this.url,\n headers: this.headers,\n body: this.body,\n query: this.query,\n params: this.params\n }\n } as any;\n\n this.response.destroy();\n this.request.destroy();\n this.#isDestroyed = true;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.#isDestroyed;\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
@@ -36,13 +36,11 @@ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequ
36
36
  * The current @@PlatformRequest@@.
37
37
  */
38
38
  readonly request: PReq;
39
- private ignoreUrlPatterns;
40
- constructor(options: PlatformContextOptions);
41
39
  /**
42
40
  * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
43
41
  */
44
- get endpoint(): EndpointMetadata;
45
- set endpoint(endpoint: EndpointMetadata);
42
+ endpoint: EndpointMetadata;
43
+ constructor(options: PlatformContextOptions);
46
44
  get url(): string;
47
45
  get app(): PlatformApplication<TsED.Application, TsED.Router>;
48
46
  destroy(): Promise<void>;
@@ -67,5 +65,4 @@ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequ
67
65
  * Return the original application instance.
68
66
  */
69
67
  getApp<T = any>(): T;
70
- upgrade(event: IncomingEvent): void;
71
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "6.122.3",
3
+ "version": "6.124.0",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -62,22 +62,22 @@
62
62
  }
63
63
  ],
64
64
  "dependencies": {
65
- "@tsed/components-scan": "6.122.3",
66
- "@tsed/core": "6.122.3",
67
- "@tsed/di": "6.122.3",
68
- "@tsed/exceptions": "6.122.3",
69
- "@tsed/json-mapper": "6.122.3",
65
+ "@tsed/components-scan": "6.124.0",
66
+ "@tsed/core": "6.124.0",
67
+ "@tsed/di": "6.124.0",
68
+ "@tsed/exceptions": "6.124.0",
69
+ "@tsed/json-mapper": "6.124.0",
70
70
  "@tsed/logger": ">=6.2.0",
71
71
  "@tsed/logger-file": ">=6.2.0",
72
- "@tsed/perf": "6.122.3",
73
- "@tsed/platform-cache": "6.122.3",
74
- "@tsed/platform-exceptions": "6.122.3",
75
- "@tsed/platform-log-middleware": "6.122.3",
76
- "@tsed/platform-middlewares": "6.122.3",
77
- "@tsed/platform-params": "6.122.3",
78
- "@tsed/platform-response-filter": "6.122.3",
79
- "@tsed/platform-views": "6.122.3",
80
- "@tsed/schema": "6.122.3",
72
+ "@tsed/perf": "6.124.0",
73
+ "@tsed/platform-cache": "6.124.0",
74
+ "@tsed/platform-exceptions": "6.124.0",
75
+ "@tsed/platform-log-middleware": "6.124.0",
76
+ "@tsed/platform-middlewares": "6.124.0",
77
+ "@tsed/platform-params": "6.124.0",
78
+ "@tsed/platform-response-filter": "6.124.0",
79
+ "@tsed/platform-views": "6.124.0",
80
+ "@tsed/schema": "6.124.0",
81
81
  "@types/json-schema": "7.0.11",
82
82
  "@types/on-finished": "2.3.1",
83
83
  "on-finished": "2.4.1",