@tsed/common 6.128.0 → 6.128.3

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.
Files changed (41) hide show
  1. package/coverage.json +6 -0
  2. package/jest.config.js +1 -6
  3. package/lib/cjs/builder/PlatformBuilder.js +1 -1
  4. package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
  5. package/lib/cjs/domain/PlatformContext.js +11 -21
  6. package/lib/cjs/domain/PlatformContext.js.map +1 -1
  7. package/lib/cjs/services/PlatformAdapter.js.map +1 -1
  8. package/lib/cjs/services/PlatformHandler.js +20 -22
  9. package/lib/cjs/services/PlatformHandler.js.map +1 -1
  10. package/lib/cjs/services/PlatformRequest.js +0 -1
  11. package/lib/cjs/services/PlatformRequest.js.map +1 -1
  12. package/lib/cjs/services/PlatformResponse.js +5 -12
  13. package/lib/cjs/services/PlatformResponse.js.map +1 -1
  14. package/lib/cjs/services/PlatformRouter.js +1 -1
  15. package/lib/cjs/services/PlatformRouter.js.map +1 -1
  16. package/lib/cjs/utils/createContext.js +5 -8
  17. package/lib/cjs/utils/createContext.js.map +1 -1
  18. package/lib/cjs/utils/setResponseHeaders.js +1 -1
  19. package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
  20. package/lib/esm/builder/PlatformBuilder.js +1 -1
  21. package/lib/esm/builder/PlatformBuilder.js.map +1 -1
  22. package/lib/esm/domain/PlatformContext.js +11 -21
  23. package/lib/esm/domain/PlatformContext.js.map +1 -1
  24. package/lib/esm/services/PlatformAdapter.js.map +1 -1
  25. package/lib/esm/services/PlatformHandler.js +20 -22
  26. package/lib/esm/services/PlatformHandler.js.map +1 -1
  27. package/lib/esm/services/PlatformRequest.js +0 -1
  28. package/lib/esm/services/PlatformRequest.js.map +1 -1
  29. package/lib/esm/services/PlatformResponse.js +5 -12
  30. package/lib/esm/services/PlatformResponse.js.map +1 -1
  31. package/lib/esm/services/PlatformRouter.js +2 -2
  32. package/lib/esm/services/PlatformRouter.js.map +1 -1
  33. package/lib/esm/utils/createContext.js +5 -8
  34. package/lib/esm/utils/createContext.js.map +1 -1
  35. package/lib/esm/utils/setResponseHeaders.js +1 -1
  36. package/lib/esm/utils/setResponseHeaders.js.map +1 -1
  37. package/lib/types/domain/PlatformContext.d.ts +5 -3
  38. package/lib/types/services/PlatformAdapter.d.ts +3 -1
  39. package/lib/types/services/PlatformRequest.d.ts +0 -1
  40. package/lib/types/services/PlatformResponse.d.ts +2 -4
  41. package/package.json +15 -15
@@ -1,3 +1,4 @@
1
+ import { setContext } from "@tsed/di";
1
2
  import { v4 } from "uuid";
2
3
  import { PlatformContext } from "../domain/PlatformContext.js";
3
4
  import { PlatformRequest } from "../services/PlatformRequest.js";
@@ -32,18 +33,14 @@ export function createContext(injector) {
32
33
  };
33
34
  const ignoreLog = buildIgnoreLog(loggerOptions.ignoreUrlPatterns);
34
35
  return async function invokeContext(event) {
35
- const ctx = new PlatformContext({
36
+ const $ctx = new PlatformContext({
36
37
  ...opts,
37
38
  event,
38
39
  id: reqIdBuilder(event.request)
39
40
  });
40
- ignoreLog && ctx.logger.alterIgnoreLog((ignore, data) => ignoreLog(ignore, data, ctx.url));
41
- ctx.response.onEnd(async () => {
42
- await ctx.emit("$onResponse", ctx);
43
- await ctx.destroy();
44
- });
45
- await ctx.emit("$onRequest", ctx);
46
- return ctx;
41
+ setContext($ctx);
42
+ ignoreLog && $ctx.logger.alterIgnoreLog((ignore, data) => ignoreLog(ignore, data, $ctx.url));
43
+ return $ctx;
47
44
  };
48
45
  }
49
46
  //# sourceMappingURL=createContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,g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F,MAAM,SAAS,GAAG,cAAc,CAAC,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAElE,OAAO,KAAK,UAAU,aAAa,CAAC,KAAoB;QACtD,MAAM,GAAG,GAAG,IAAI,eAAe,CAAC;YAC9B,GAAG,IAAI;YACP,KAAK;YACL,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;SAChC,CAAC,CAAC;QAEH,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QAE3F,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YAC5B,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {v4} from \"uuid\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\nfunction defaultReqIdBuilder(req: any) {\n return req.get(\"x-request-id\") || v4().split(\"-\").join(\"\");\n}\n\nfunction mapIgnoreUrlPatterns(ignoreUrlPatterns: any[]) {\n return ignoreUrlPatterns.map((pattern: string | RegExp) => (typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern));\n}\n\nexport function buildIgnoreLog(ignoreUrlPatterns: any[] | undefined) {\n if (ignoreUrlPatterns) {\n ignoreUrlPatterns = mapIgnoreUrlPatterns(ignoreUrlPatterns);\n return (ignore: boolean, data: any, url: string) => ignoreUrlPatterns?.find((reg) => !!url.match(reg));\n }\n}\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger;\n\n const opts = {\n ...loggerOptions,\n logger: injector.logger,\n injector,\n ResponseKlass,\n RequestKlass\n };\n\n const ignoreLog = buildIgnoreLog(loggerOptions.ignoreUrlPatterns);\n\n return async function invokeContext(event: IncomingEvent) {\n const ctx = new PlatformContext({\n ...opts,\n event,\n id: reqIdBuilder(event.request)\n });\n\n ignoreLog && ctx.logger.alterIgnoreLog((ignore, data) => ignoreLog(ignore, data, ctx.url));\n\n ctx.response.onEnd(async () => {\n await ctx.emit(\"$onResponse\", ctx);\n await ctx.destroy();\n });\n\n await ctx.emit(\"$onRequest\", ctx);\n\n return ctx;\n };\n}\n"]}
1
+ {"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,UAAU,EAAC,MAAM,UAAU,CAAC;AACrD,OAAO,EAAC,EAAE,EAAC,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAE9D,SAAS,mBAAmB,CAAC,GAAQ;IACnC,OAAO,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAC7D,CAAC;AAED,SAAS,oBAAoB,CAAC,iBAAwB;IACpD,OAAO,iBAA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AAC,IAAI,CAAC,CAAC;QAEjB,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;QAE7F,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {InjectorService, setContext} from \"@tsed/di\";\nimport {v4} from \"uuid\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\nfunction defaultReqIdBuilder(req: any) {\n return req.get(\"x-request-id\") || v4().split(\"-\").join(\"\");\n}\n\nfunction mapIgnoreUrlPatterns(ignoreUrlPatterns: any[]) {\n return ignoreUrlPatterns.map((pattern: string | RegExp) => (typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern));\n}\n\nexport function buildIgnoreLog(ignoreUrlPatterns: any[] | undefined) {\n if (ignoreUrlPatterns) {\n ignoreUrlPatterns = mapIgnoreUrlPatterns(ignoreUrlPatterns);\n return (ignore: boolean, data: any, url: string) => ignoreUrlPatterns?.find((reg) => !!url.match(reg));\n }\n}\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger;\n\n const opts = {\n ...loggerOptions,\n logger: injector.logger,\n injector,\n ResponseKlass,\n RequestKlass\n };\n\n const ignoreLog = buildIgnoreLog(loggerOptions.ignoreUrlPatterns);\n\n return async function invokeContext(event: IncomingEvent) {\n const $ctx = new PlatformContext({\n ...opts,\n event,\n id: reqIdBuilder(event.request)\n });\n\n setContext($ctx);\n\n ignoreLog && $ctx.logger.alterIgnoreLog((ignore, data) => ignoreLog(ignore, data, $ctx.url));\n\n return $ctx;\n };\n}\n"]}
@@ -4,7 +4,7 @@
4
4
  export function setResponseHeaders(ctx) {
5
5
  const { response, endpoint } = ctx;
6
6
  const { operation } = endpoint;
7
- if (response.isDone()) {
7
+ if (ctx.isDone()) {
8
8
  return;
9
9
  }
10
10
  if (!response.hasStatus()) {
@@ -1 +1 @@
1
- {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzD;AACH,CAAC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(statusCode);\n\n Object.entries(headers).forEach(([key, item]) => {\n if (!response.get(key)) {\n response.setHeader(key, String(item.example));\n }\n });\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, response.get(\"location\"));\n }\n}\n"]}
1
+ {"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,GAAG,CAAC,MAAM,EAAE,EAAE;QAChB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QAC9C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE;YACtB,QAAQ,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;SAC/C;IACH,CAAC,CAAC,CAAC;IAEH,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;KACzD;AACH,CAAC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (ctx.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(statusCode);\n\n Object.entries(headers).forEach(([key, item]) => {\n if (!response.get(key)) {\n response.setHeader(key, String(item.example));\n }\n });\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, response.get(\"location\"));\n }\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ContextMethods, DIContext, DIContextOptions } from "@tsed/di";
2
+ import { DIContext, DIContextOptions } from "@tsed/di";
3
3
  import { EndpointMetadata } from "@tsed/schema";
4
4
  import { IncomingMessage, ServerResponse } from "http";
5
5
  import { IncomingEvent } from "../interfaces/IncomingEvent";
@@ -17,7 +17,7 @@ export interface PlatformContextOptions extends DIContextOptions {
17
17
  ignoreUrlPatterns?: any[];
18
18
  endpoint?: EndpointMetadata;
19
19
  }
20
- export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext implements ContextMethods {
20
+ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext {
21
21
  #private;
22
22
  event: IncomingEvent;
23
23
  /**
@@ -43,7 +43,9 @@ export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequ
43
43
  constructor(options: PlatformContextOptions);
44
44
  get url(): string;
45
45
  get app(): PlatformApplication<TsED.Application, TsED.Router>;
46
- destroy(): Promise<void>;
46
+ start(): Promise<void>;
47
+ finish(): Promise<void>;
48
+ isFinished(): boolean;
47
49
  isDone(): any;
48
50
  /**
49
51
  * Return the framework request instance (Express, Koa, etc...)
@@ -1,5 +1,7 @@
1
+ /// <reference types="node" />
1
2
  import { Type } from "@tsed/core";
2
3
  import { ProviderOpts } from "@tsed/di";
4
+ import { IncomingMessage, ServerResponse } from "http";
3
5
  import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
4
6
  import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
5
7
  import { RouterOptions } from "express";
@@ -18,7 +20,7 @@ export declare abstract class PlatformAdapter<App = TsED.Application, Router = T
18
20
  useContext?: () => any;
19
21
  abstract app(): {
20
22
  app: App;
21
- callback(): any;
23
+ callback(): (req: IncomingMessage, res: ServerResponse) => void;
22
24
  };
23
25
  abstract router(routerOptions?: Partial<RouterOptions>): {
24
26
  router: Router;
@@ -103,7 +103,6 @@ export declare class PlatformRequest<Req extends {
103
103
  accepts(mime: string): string | false;
104
104
  accepts(mime: string[]): string[] | false;
105
105
  isAborted(): any;
106
- destroy(): void;
107
106
  /**
108
107
  * Return the Framework response object (express, koa, etc...)
109
108
  */
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { OutgoingHttpHeaders, ServerResponse } from "http";
3
- import type { PlatformRequest } from "./PlatformRequest";
4
3
  import type { PlatformContext } from "../domain/PlatformContext";
4
+ import type { PlatformRequest } from "./PlatformRequest";
5
5
  declare global {
6
6
  namespace TsED {
7
7
  interface Response {
@@ -40,7 +40,6 @@ export declare class PlatformResponse<Res extends Record<string, any> = any> {
40
40
  * Return the original response node.js instance
41
41
  */
42
42
  get res(): ServerResponse;
43
- static onFinished(res: any, cb: (er: Error | null, message: string) => void): void;
44
43
  /**
45
44
  * Returns the HTTP response header specified by field. The match is case-insensitive.
46
45
  *
@@ -153,8 +152,7 @@ export declare class PlatformResponse<Res extends Record<string, any> = any> {
153
152
  * Add a listener to handler the end of the request/response.
154
153
  * @param cb
155
154
  */
156
- onEnd(cb: (er: Error | null, message: string) => void): this;
155
+ onEnd(cb: () => Promise<void> | void): this;
157
156
  isDone(): boolean;
158
- destroy(): void;
159
157
  isHeadersSent(): boolean;
160
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "6.128.0",
3
+ "version": "6.128.3",
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.128.0",
66
- "@tsed/core": "6.128.0",
67
- "@tsed/di": "6.128.0",
68
- "@tsed/exceptions": "6.128.0",
69
- "@tsed/json-mapper": "6.128.0",
65
+ "@tsed/components-scan": "6.128.3",
66
+ "@tsed/core": "6.128.3",
67
+ "@tsed/di": "6.128.3",
68
+ "@tsed/exceptions": "6.128.3",
69
+ "@tsed/json-mapper": "6.128.3",
70
70
  "@tsed/logger": ">=6.2.0",
71
71
  "@tsed/logger-file": ">=6.2.0",
72
- "@tsed/perf": "6.128.0",
73
- "@tsed/platform-cache": "6.128.0",
74
- "@tsed/platform-exceptions": "6.128.0",
75
- "@tsed/platform-log-middleware": "6.128.0",
76
- "@tsed/platform-middlewares": "6.128.0",
77
- "@tsed/platform-params": "6.128.0",
78
- "@tsed/platform-response-filter": "6.128.0",
79
- "@tsed/platform-views": "6.128.0",
80
- "@tsed/schema": "6.128.0",
72
+ "@tsed/perf": "6.128.3",
73
+ "@tsed/platform-cache": "6.128.3",
74
+ "@tsed/platform-exceptions": "6.128.3",
75
+ "@tsed/platform-log-middleware": "6.128.3",
76
+ "@tsed/platform-middlewares": "6.128.3",
77
+ "@tsed/platform-params": "6.128.3",
78
+ "@tsed/platform-response-filter": "6.128.3",
79
+ "@tsed/platform-views": "6.128.3",
80
+ "@tsed/schema": "6.128.3",
81
81
  "@types/json-schema": "7.0.11",
82
82
  "@types/on-finished": "2.3.1",
83
83
  "on-finished": "2.4.1",