@tsed/platform-router 8.11.0 → 8.11.2-rc.1

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.
@@ -107,4 +107,3 @@ export class PlatformHandlerMetadata {
107
107
  return [nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
108
108
  }
109
109
  }
110
- //# sourceMappingURL=PlatformHandlerMetadata.js.map
@@ -9,4 +9,3 @@ export var PlatformHandlerType;
9
9
  PlatformHandlerType["RAW_FN"] = "raw:middleware";
10
10
  PlatformHandlerType["RAW_ERR_FN"] = "raw:err:middleware";
11
11
  })(PlatformHandlerType || (PlatformHandlerType = {}));
12
- //# sourceMappingURL=PlatformHandlerType.js.map
@@ -50,4 +50,3 @@ export class PlatformLayer {
50
50
  });
51
51
  }
52
52
  }
53
- //# sourceMappingURL=PlatformLayer.js.map
@@ -103,4 +103,3 @@ export class PlatformRouter {
103
103
  }
104
104
  }
105
105
  injectable(PlatformRouter).scope(ProviderScope.INSTANCE);
106
- //# sourceMappingURL=PlatformRouter.js.map
@@ -132,4 +132,3 @@ $on(`$beforeInvoke:${ProviderType.CONTROLLER}`, ({ provider, locals }) => {
132
132
  const router = createInjectableRouter(provider);
133
133
  locals.set(PlatformRouter, router);
134
134
  });
135
- //# sourceMappingURL=PlatformRouters.js.map
@@ -1,2 +1 @@
1
1
  export {};
2
- //# sourceMappingURL=SinglePathType.js.map
package/lib/esm/index.js CHANGED
@@ -9,4 +9,3 @@ export * from "./domain/PlatformRouters.js";
9
9
  export * from "./domain/SinglePathType.js";
10
10
  export * from "./utils/formatMethod.js";
11
11
  export * from "./utils/useContextHandler.js";
12
- //# sourceMappingURL=index.js.map
@@ -2,4 +2,3 @@ import { OperationVerbs } from "@tsed/schema";
2
2
  export function formatMethod(method) {
3
3
  return (method === OperationVerbs.CUSTOM ? "use" : method || "use").toLowerCase();
4
4
  }
5
- //# sourceMappingURL=formatMethod.js.map
@@ -12,4 +12,3 @@ export function useResponseHandler(fn) {
12
12
  fn.type = PlatformHandlerType.RESPONSE_FN;
13
13
  return fn;
14
14
  }
15
- //# sourceMappingURL=useContextHandler.js.map
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@tsed/platform-router",
3
3
  "description": "Router",
4
4
  "type": "module",
5
- "version": "8.11.0",
5
+ "version": "8.11.2-rc.1",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -26,14 +26,14 @@
26
26
  "tslib": "2.7.0"
27
27
  },
28
28
  "devDependencies": {
29
- "@tsed/barrels": "8.11.0",
30
- "@tsed/core": "8.11.0",
31
- "@tsed/di": "8.11.0",
32
- "@tsed/exceptions": "8.11.0",
33
- "@tsed/json-mapper": "8.11.0",
34
- "@tsed/platform-params": "8.11.0",
35
- "@tsed/schema": "8.11.0",
36
- "@tsed/typescript": "8.11.0",
29
+ "@tsed/barrels": "8.11.2-rc.1",
30
+ "@tsed/core": "8.11.2-rc.1",
31
+ "@tsed/di": "8.11.2-rc.1",
32
+ "@tsed/exceptions": "8.11.2-rc.1",
33
+ "@tsed/json-mapper": "8.11.2-rc.1",
34
+ "@tsed/platform-params": "8.11.2-rc.1",
35
+ "@tsed/schema": "8.11.2-rc.1",
36
+ "@tsed/typescript": "8.11.2-rc.1",
37
37
  "eslint": "9.12.0",
38
38
  "typescript": "5.4.5",
39
39
  "vitest": "3.1.4"
@@ -72,5 +72,8 @@
72
72
  },
73
73
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/platform/platform-router",
74
74
  "author": "Romain Lenzotti",
75
- "license": "MIT"
75
+ "license": "MIT",
76
+ "publishConfig": {
77
+ "tag": "rc"
78
+ }
76
79
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/PlatformHandlerMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,YAAY,CAAC;AAClC,OAA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AIG;IACI,eAAe;QACpB,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,mBAAmB,CAAC,UAAU,CAAC,CAAC;IAC5H,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3E,CAAC;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformHandlerType.js","sourceRoot":"","sources":["../../../src/domain/PlatformHandlerType.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,mBASX;AATD,WAAY,mBAAmB;IAC7B,wCAAiB,CAAA;IACjB,4CAAqB,CAAA;IACrB,gDAAyB,CAAA;IACzB,wDAAiC,CAAA;IACjC,yCAAkB,CAAA;IAClB,+CAAwB,CAAA;IACxB,gDAAyB,CAAA;IACzB,wDAAiC,CAAA;AACnC,CAAC,EATW,mBAAmB,KAAnB,mBAAmB,QAS9B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PlatformLayer.js","sourceRoot":"","sources":["../../../src/domain/PlatformLayer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,MAAM,EAAO,MAAM,YAAY,CAAC;AAGrD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAqBxC,MAAM,OAAO,aAAa;IAYxB,KAAK,CAA2B;IAEhC,YAAY,QAAqC,EAAE;QAZ5C,SAAI,GAAmB,EAAE,CAAC;QAE1B,aAAQ,GAA8B,EAAE,CAAC;QAEzC,SAAI,GAAyB,EAAE,CAAC;QAEhC,WAAM,GAAoB,EAAE,CAAC;QAOlC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAE3B,IAAI,CAAC,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;YAED,OAAO,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACb,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE;gBACtD,4DAA4D;gBAC5D,eAAe,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;gBAElC,IAAI,eAAe,CAAC,OAAO,EAAE,EAAE,CAAC;oBAC9B,OAAO,eAAe,CAAC,OAAO,CAAC;gBACjC,CAAC;gBAED,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAkD,cAAc,EAAE,eAAe,CAAC,CAAC;YAC5G,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAEpB,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACP,CAAC;CACF;AAED,UAAU,CAAC,eAAe,CAAC,CAAC;AAC5B;;;GAGG;AACH,GAAG,CAAC,iBAAiB,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,EAAC,QAAQ,EAAE,MAAM,EAAwB,EAAE,EAAE;IAC5F,MAAM,MAAM,GAAG,sBAAsB,CAAC,QAA8B,CAAC,CAAC;IACtE,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"SinglePathType.js","sourceRoot":"","sources":["../../../src/domain/SinglePathType.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatMethod.js","sourceRoot":"","sources":["../../../src/utils/formatMethod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,YAAY,CAAC,MAA0B;IACrD,OAAO,CAAC,MAAM,KAAK,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;AACpF,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useContextHandler.js","sourceRoot":"","sources":["../../../src/utils/useContextHandler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAIrE;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,EAAyD;IACzF,EAAE,CAAC,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC;IAErC,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,EAAyD;IAC1F,EAAE,CAAC,IAAI,GAAG,mBAAmB,CAAC,WAAW,CAAC;IAE1C,OAAO,EAAE,CAAC;AACZ,CAAC"}
@@ -1,155 +0,0 @@
1
- import {Controller, destroyInjector, injector} from "@tsed/di";
2
- import {Err, Next, Req} from "@tsed/platform-http";
3
- import {Middleware} from "@tsed/platform-middlewares";
4
- import {Get, JsonMethodStore} from "@tsed/schema";
5
-
6
- import {useContextHandler} from "../utils/useContextHandler.js";
7
- import {PlatformHandlerMetadata} from "./PlatformHandlerMetadata.js";
8
- import {PlatformHandlerType} from "./PlatformHandlerType.js";
9
-
10
- describe("PlatformHandlerMetadata", () => {
11
- afterEach(() => destroyInjector());
12
- describe("from()", () => {
13
- it("should return PlatformMetadata", () => {
14
- const meta = new PlatformHandlerMetadata({
15
- type: PlatformHandlerType.CUSTOM,
16
- handler: () => {}
17
- });
18
- const result = PlatformHandlerMetadata.from(meta);
19
- expect(result).toEqual(meta);
20
- });
21
- });
22
- describe("from useContextHandler", () => {
23
- it("should create a new handlerMetadata with right metadata", () => {
24
- // GIVEN
25
- const handler = useContextHandler((ctx: any) => {});
26
-
27
- // WHEN
28
- const handlerMetadata = new PlatformHandlerMetadata({
29
- handler
30
- });
31
-
32
- // THEN
33
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.CTX_FN);
34
- expect(handlerMetadata.hasNextFunction).toEqual(false);
35
- expect(handlerMetadata.hasErrorParam).toEqual(false);
36
- expect(handlerMetadata.toString()).toEqual("");
37
- expect(handlerMetadata.isRawMiddleware()).toEqual(false);
38
- });
39
- });
40
- describe("from function", () => {
41
- it("should create a new handlerMetadata with right metadata", () => {
42
- // GIVEN
43
- const options = {
44
- handler(req: any, res: any, next: any) {}
45
- };
46
- // WHEN
47
- const handlerMetadata = new PlatformHandlerMetadata(options);
48
-
49
- // THEN
50
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.RAW_FN);
51
- expect(handlerMetadata.hasNextFunction).toEqual(true);
52
- expect(handlerMetadata.hasErrorParam).toEqual(false);
53
- expect(handlerMetadata.toString()).toEqual("handler");
54
- expect(handlerMetadata.isRawMiddleware()).toEqual(true);
55
- });
56
- });
57
- describe("from function err", () => {
58
- it("should create a new handlerMetadata with right metadata", () => {
59
- // GIVEN
60
- const options = {
61
- handler(err: any, req: any, res: any, next: any) {}
62
- };
63
- // WHEN
64
- const handlerMetadata = new PlatformHandlerMetadata(options);
65
-
66
- // THEN
67
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.RAW_ERR_FN);
68
- expect(handlerMetadata.hasNextFunction).toEqual(true);
69
- expect(handlerMetadata.hasErrorParam).toEqual(true);
70
- expect(handlerMetadata.propertyKey).toBeUndefined();
71
- expect(handlerMetadata.toString()).toEqual("handler");
72
- expect(handlerMetadata.isRawMiddleware()).toEqual(true);
73
- });
74
- });
75
- describe("from function without nextFn", () => {
76
- it("should create a new handlerMetadata with right metadata", () => {
77
- // GIVEN
78
- const options = {
79
- handler(req: any, res: any) {}
80
- };
81
-
82
- // WHEN
83
- const handlerMetadata = new PlatformHandlerMetadata(options);
84
-
85
- // THEN
86
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.RAW_FN);
87
- expect(handlerMetadata.hasNextFunction).toEqual(false);
88
- expect(handlerMetadata.hasErrorParam).toEqual(false);
89
- expect(handlerMetadata.propertyKey).toBeUndefined();
90
- expect(handlerMetadata.toString()).toEqual("handler");
91
- expect(handlerMetadata.isRawMiddleware()).toEqual(true);
92
- });
93
- });
94
- describe("from endpoint/middleware with injection", () => {
95
- it("should create a new handlerMetadata with right metadata", () => {
96
- // GIVEN
97
- @Controller("/")
98
- class Test {
99
- @Get("/")
100
- test(@Req() req: Req, @Next() next: Next) {}
101
- }
102
-
103
- injector().addProvider(Test);
104
-
105
- const options = {
106
- provider: injector().getProvider(Test),
107
- propertyKey: "test",
108
- type: PlatformHandlerType.ENDPOINT
109
- };
110
- // WHEN
111
- const handlerMetadata = new PlatformHandlerMetadata(options);
112
-
113
- // THEN
114
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.ENDPOINT);
115
- expect(handlerMetadata.hasNextFunction).toEqual(true);
116
- expect(handlerMetadata.hasErrorParam).toEqual(false);
117
- expect(handlerMetadata.propertyKey).toEqual("test");
118
- expect(handlerMetadata.scope).toEqual("singleton");
119
- expect(handlerMetadata.toString()).toEqual("Test.test");
120
- expect(handlerMetadata.store).toBeInstanceOf(JsonMethodStore);
121
-
122
- expect(handlerMetadata.getParams()[0].paramType).toEqual("REQUEST");
123
- expect(handlerMetadata.getParams()[1].paramType).toEqual("NEXT_FN");
124
- expect(handlerMetadata.isRawMiddleware()).toEqual(false);
125
- });
126
- });
127
-
128
- describe("from middleware with injection and error", () => {
129
- it("should create a new handlerMetadata with right metadata", () => {
130
- // WHEN
131
- @Middleware()
132
- class Test {
133
- use(@Err() error: any, @Next() next: Next) {}
134
- }
135
-
136
- injector().addProvider(Test);
137
-
138
- const options = {
139
- provider: injector().getProvider(Test),
140
- propertyKey: "use",
141
- type: PlatformHandlerType.MIDDLEWARE
142
- };
143
- // WHEN
144
- const handlerMetadata = new PlatformHandlerMetadata(options);
145
-
146
- // THEN
147
- expect(handlerMetadata.type).toEqual(PlatformHandlerType.ERR_MIDDLEWARE);
148
- expect(handlerMetadata.hasNextFunction).toEqual(true);
149
- expect(handlerMetadata.hasErrorParam).toEqual(true);
150
- expect(handlerMetadata.propertyKey).toEqual("use");
151
- expect(handlerMetadata.toString()).toEqual("Test.use");
152
- expect(handlerMetadata.isRawMiddleware()).toEqual(false);
153
- });
154
- });
155
- });
@@ -1,154 +0,0 @@
1
- import {nameOf} from "@tsed/core";
2
- import {DIContext, injector, Provider, ProviderScope, TokenProvider} from "@tsed/di";
3
- import {ParamTypes} from "@tsed/platform-params";
4
- import {EndpointMetadata, JsonEntityStore, JsonParameterStore} from "@tsed/schema";
5
-
6
- import {PlatformHandlerType} from "./PlatformHandlerType.js";
7
- import {SinglePathType} from "./SinglePathType.js";
8
-
9
- export interface PlatformHandlerMetadataOpts extends Record<string, any> {
10
- token?: TokenProvider;
11
- }
12
-
13
- export interface PlatformHandlerMetadataProps {
14
- provider?: Provider;
15
- handler?: any;
16
- opts?: PlatformHandlerMetadataOpts;
17
- propertyKey?: string | symbol;
18
- type?: PlatformHandlerType;
19
- }
20
-
21
- export class PlatformHandlerMetadata {
22
- path: SinglePathType;
23
-
24
- readonly provider?: Provider;
25
- readonly propertyKey: string | symbol;
26
- readonly type: PlatformHandlerType = PlatformHandlerType.RAW_FN;
27
- readonly hasNextFunction: boolean = false;
28
- readonly opts: PlatformHandlerMetadataOpts = {};
29
- compiledHandler: ($ctx: DIContext) => any;
30
- #handler: any;
31
-
32
- constructor(props: PlatformHandlerMetadataProps) {
33
- const {propertyKey, type, provider, handler, opts} = props;
34
-
35
- this.provider = provider;
36
- this.type = type || handler.type || PlatformHandlerType.RAW_FN;
37
- this.opts = opts || {};
38
-
39
- this.#handler = propertyKey ? this.target.prototype[propertyKey] : handler;
40
-
41
- if (propertyKey) {
42
- this.propertyKey = propertyKey;
43
- this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);
44
-
45
- if (this.hasParamType(ParamTypes.ERR)) {
46
- this.type = PlatformHandlerType.ERR_MIDDLEWARE;
47
- }
48
- } else {
49
- if (this.#handler.length === 4) {
50
- this.type = PlatformHandlerType.RAW_ERR_FN;
51
- }
52
- this.hasNextFunction = this.#handler.length >= 3;
53
- }
54
- }
55
-
56
- get target() {
57
- return this.provider?.useClass || this.#handler;
58
- }
59
-
60
- get token() {
61
- return this.provider?.token || this.#handler;
62
- }
63
-
64
- get handler() {
65
- return this.#handler;
66
- }
67
-
68
- get scope() {
69
- return this.provider?.scope || ProviderScope.SINGLETON;
70
- }
71
-
72
- get hasErrorParam() {
73
- return this.type === PlatformHandlerType.ERR_MIDDLEWARE || this.type === PlatformHandlerType.RAW_ERR_FN;
74
- }
75
-
76
- get store() {
77
- return JsonEntityStore.fromMethod(this.provider!.useClass, this.propertyKey!);
78
- }
79
-
80
- static from(input: any, opts: PlatformHandlerMetadataOpts = {}): PlatformHandlerMetadata {
81
- if (input instanceof PlatformHandlerMetadata) {
82
- return input;
83
- }
84
-
85
- if (input instanceof EndpointMetadata) {
86
- const provider = injector().getProvider(opts.token)!;
87
-
88
- return new PlatformHandlerMetadata({
89
- provider,
90
- type: PlatformHandlerType.ENDPOINT,
91
- propertyKey: input.propertyKey,
92
- opts
93
- });
94
- }
95
-
96
- const provider = injector().getProvider(input);
97
-
98
- if (provider) {
99
- return new PlatformHandlerMetadata({
100
- provider,
101
- type: PlatformHandlerType.MIDDLEWARE,
102
- propertyKey: "use",
103
- opts
104
- });
105
- }
106
-
107
- return new PlatformHandlerMetadata({
108
- handler: input,
109
- type: input.type,
110
- opts
111
- });
112
- }
113
-
114
- public getParams() {
115
- return JsonParameterStore.getParams(this.target, this.propertyKey) || [];
116
- }
117
-
118
- public hasParamType(paramType: any): boolean {
119
- return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
120
- }
121
-
122
- public isInjectable() {
123
- return !(this.isRawFn() || this.isResponseFn());
124
- }
125
-
126
- public isRawFn() {
127
- return this.type === PlatformHandlerType.RAW_ERR_FN || this.type === PlatformHandlerType.RAW_FN;
128
- }
129
-
130
- public isEndpoint() {
131
- return this.type === PlatformHandlerType.ENDPOINT;
132
- }
133
-
134
- public isCtxFn() {
135
- return this.type === PlatformHandlerType.CTX_FN;
136
- }
137
-
138
- public isResponseFn() {
139
- return this.type === PlatformHandlerType.RESPONSE_FN;
140
- }
141
-
142
- /**
143
- * Checks if the handler is a raw middleware function.
144
- * Raw middleware functions are non-injectable handlers of type RAW_FN or RAW_ERR_FN.
145
- * @returns {boolean} True if the handler is a raw middleware function
146
- */
147
- public isRawMiddleware(): boolean {
148
- return !this.isInjectable() && (this.type === PlatformHandlerType.RAW_FN || this.type === PlatformHandlerType.RAW_ERR_FN);
149
- }
150
-
151
- toString() {
152
- return [nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
153
- }
154
- }
@@ -1,10 +0,0 @@
1
- export enum PlatformHandlerType {
2
- CUSTOM = "custom",
3
- ENDPOINT = "endpoint",
4
- MIDDLEWARE = "middleware",
5
- ERR_MIDDLEWARE = "err:middleware",
6
- CTX_FN = "context",
7
- RESPONSE_FN = "response",
8
- RAW_FN = "raw:middleware",
9
- RAW_ERR_FN = "raw:err:middleware"
10
- }
@@ -1,89 +0,0 @@
1
- import {isPrimitive, nameOf, Type} from "@tsed/core";
2
- import {Provider} from "@tsed/di";
3
- import type {PlatformParamsCallback} from "@tsed/platform-params";
4
- import {concatPath} from "@tsed/schema";
5
-
6
- import {PlatformHandlerMetadata} from "./PlatformHandlerMetadata.js";
7
- import type {PlatformRouter} from "./PlatformRouter.js";
8
- import {SinglePathType} from "./SinglePathType.js";
9
-
10
- export interface PlatformLayerOptions extends Record<string, any> {
11
- token?: Type<any>;
12
- }
13
-
14
- export interface PlatformLayerProps {
15
- parent: PlatformLayer;
16
- provider: Provider;
17
- path: SinglePathType;
18
- basePath: SinglePathType;
19
- method: string;
20
- handlers: any[];
21
- router: PlatformRouter;
22
- opts: PlatformLayerOptions;
23
- }
24
-
25
- export class PlatformLayer {
26
- public provider: Provider;
27
- public path: SinglePathType = "";
28
- public method: string;
29
- public handlers: PlatformHandlerMetadata[] = [];
30
- public router?: PlatformRouter;
31
- public opts: PlatformLayerOptions = {};
32
-
33
- public layers: PlatformLayer[] = [];
34
-
35
- public parent?: PlatformLayer;
36
- basePath: SinglePathType;
37
- #args: PlatformParamsCallback[];
38
-
39
- constructor(props: Partial<PlatformLayerProps> = {}) {
40
- Object.assign(this, props);
41
-
42
- this.layers = this.layers.map((layer) => {
43
- return new PlatformLayer({
44
- ...layer,
45
- parent: this
46
- });
47
- });
48
- }
49
-
50
- set(args: PlatformParamsCallback[]) {
51
- this.#args = args;
52
- }
53
-
54
- getArgs() {
55
- return [this.path, ...this.#args].filter(Boolean);
56
- }
57
-
58
- isProvider() {
59
- return !!this.provider;
60
- }
61
-
62
- inspect() {
63
- return {
64
- basePath: this.getBasePath(),
65
- path: this.path,
66
- method: this.method,
67
- handlers: this.handlers.map((item: any) => String(item)),
68
- opts: Object.entries(this.opts).reduce((obj, [key, value]) => {
69
- return {
70
- ...obj,
71
- [key]: isPrimitive(value) ? value : nameOf(value)
72
- };
73
- }, {})
74
- };
75
- }
76
-
77
- getBasePath(): string {
78
- return concatPath(this.parent?.getBasePath(), this.basePath);
79
- }
80
-
81
- setLayers(layers: PlatformLayer[]) {
82
- this.layers = layers.map((layer) => {
83
- return new PlatformLayer({
84
- ...layer,
85
- parent: this
86
- });
87
- });
88
- }
89
- }
@@ -1,131 +0,0 @@
1
- import {isString} from "@tsed/core";
2
- import {injectable, Provider, ProviderScope} from "@tsed/di";
3
- import {concatPath} from "@tsed/schema";
4
-
5
- import {formatMethod} from "../utils/formatMethod.js";
6
- import {PlatformHandlerMetadata} from "./PlatformHandlerMetadata.js";
7
- import {PlatformLayer, PlatformLayerOptions} from "./PlatformLayer.js";
8
- import {SinglePathType} from "./SinglePathType.js";
9
-
10
- function printHandler(handler: any) {
11
- return handler.toString().split("{")[0].trim();
12
- }
13
-
14
- export class PlatformRouter {
15
- readonly layers: PlatformLayer[] = [];
16
- provider: Provider;
17
- #isBuilt = false;
18
-
19
- use(...handlers: any[]) {
20
- const layer = handlers.reduce(
21
- (layer: PlatformLayer, item) => {
22
- if (isString(item) || item instanceof RegExp) {
23
- layer.path = item;
24
- layer.basePath = item;
25
- } else {
26
- if (item instanceof PlatformRouter) {
27
- layer.router = item;
28
- layer.setLayers(item.layers);
29
-
30
- if (!this.provider && item.provider) {
31
- layer.path = concatPath(layer.path, item.provider.path);
32
- } else {
33
- layer.path = layer.path || item.provider.path;
34
- }
35
- } else {
36
- item = PlatformHandlerMetadata.from(item);
37
- }
38
-
39
- layer.handlers.push(item);
40
- }
41
-
42
- return layer;
43
- },
44
- new PlatformLayer({
45
- method: "use",
46
- basePath: this.provider?.path || "/",
47
- provider: this.provider
48
- })
49
- );
50
-
51
- this.layers.push(layer);
52
-
53
- return this;
54
- }
55
-
56
- addRoute(method: string, path: SinglePathType, handlers: any[], opts: PlatformLayerOptions = {}) {
57
- const layer = new PlatformLayer({
58
- provider: this.provider,
59
- method: formatMethod(method),
60
- path,
61
- handlers: handlers.map((input) => {
62
- return PlatformHandlerMetadata.from(input, opts);
63
- }),
64
- opts
65
- });
66
-
67
- this.layers.push(layer);
68
-
69
- return this;
70
- }
71
-
72
- all(path: SinglePathType, ...handlers: any[]) {
73
- return this.addRoute("all", path, handlers);
74
- }
75
-
76
- get(path: SinglePathType, ...handlers: any[]) {
77
- return this.addRoute("get", path, handlers);
78
- }
79
-
80
- post(path: SinglePathType, ...handlers: any[]) {
81
- return this.addRoute("post", path, handlers);
82
- }
83
-
84
- put(path: SinglePathType, ...handlers: any[]) {
85
- return this.addRoute("put", path, handlers);
86
- }
87
-
88
- delete(path: SinglePathType, ...handlers: any[]) {
89
- return this.addRoute("delete", path, handlers);
90
- }
91
-
92
- patch(path: SinglePathType, ...handlers: any[]) {
93
- return this.addRoute("patch", path, handlers);
94
- }
95
-
96
- head(path: SinglePathType, ...handlers: any[]) {
97
- return this.addRoute("head", path, handlers);
98
- }
99
-
100
- options(path: SinglePathType, ...handlers: any[]) {
101
- return this.addRoute("options", path, handlers);
102
- }
103
-
104
- statics(path: string, options: any) {
105
- return this.addRoute("statics", path, [], options);
106
- }
107
-
108
- inspect() {
109
- return this.layers.map((layer) => {
110
- const obj = layer.inspect();
111
-
112
- return {
113
- ...obj,
114
- handlers: obj.handlers.map(printHandler),
115
- path: concatPath(this.provider?.path, obj.path)
116
- };
117
- });
118
- }
119
-
120
- isBuilt() {
121
- if (this.#isBuilt) {
122
- return true;
123
- }
124
-
125
- this.#isBuilt = true;
126
-
127
- return false;
128
- }
129
- }
130
-
131
- injectable(PlatformRouter).scope(ProviderScope.INSTANCE);
@@ -1,196 +0,0 @@
1
- import {getValue, Type} from "@tsed/core";
2
- import {
3
- constant,
4
- ControllerProvider,
5
- inject,
6
- injectable,
7
- injector,
8
- Provider,
9
- ProviderType,
10
- ResolvedInvokeOptions,
11
- TokenProvider
12
- } from "@tsed/di";
13
- import {$on, Hooks} from "@tsed/hooks";
14
- import {PlatformParamsCallback} from "@tsed/platform-params";
15
- import {concatPath, getOperationsRoutes, JsonMethodStore, OPERATION_HTTP_VERBS} from "@tsed/schema";
16
-
17
- import {useContextHandler} from "../utils/useContextHandler.js";
18
- import {PlatformHandlerMetadata} from "./PlatformHandlerMetadata.js";
19
- import {PlatformLayer} from "./PlatformLayer.js";
20
- import {PlatformRouter} from "./PlatformRouter.js";
21
-
22
- let AUTO_INC = 0;
23
-
24
- function getInjectableRouter(provider: Provider): PlatformRouter {
25
- return injector().get(provider.tokenRouter)!;
26
- }
27
-
28
- function createTokenRouter(provider: ControllerProvider) {
29
- return (provider.tokenRouter = provider.tokenRouter || `${provider.name}_ROUTER_${AUTO_INC++}`);
30
- }
31
-
32
- function createInjectableRouter(provider: ControllerProvider): PlatformRouter {
33
- const tokenRouter = createTokenRouter(provider);
34
-
35
- if (injector().has(tokenRouter)) {
36
- return getInjectableRouter(provider);
37
- }
38
-
39
- const router = inject<PlatformRouter>(PlatformRouter);
40
- router.provider = provider;
41
-
42
- return injector()
43
- .add(tokenRouter, {
44
- useValue: router
45
- })
46
- .invoke<PlatformRouter>(tokenRouter);
47
- }
48
-
49
- export interface AlterEndpointHandlersArg {
50
- before: (Type<any> | Function)[];
51
- endpoint: JsonMethodStore;
52
- after: (Type<any> | Function)[];
53
- }
54
-
55
- export class PlatformRouters {
56
- readonly hooks = new Hooks();
57
- readonly allowedVerbs = OPERATION_HTTP_VERBS;
58
-
59
- prebuild() {
60
- injector()
61
- .getProviders(ProviderType.CONTROLLER)
62
- .forEach((provider: ControllerProvider) => {
63
- createInjectableRouter(provider);
64
- });
65
- }
66
-
67
- from(token: TokenProvider, parentMiddlewares: any[] = []) {
68
- const provider = injector().getProvider<ControllerProvider>(token)!;
69
-
70
- if (!provider) {
71
- throw new Error("Token not found in the provider registry");
72
- }
73
-
74
- const router = createInjectableRouter(provider);
75
-
76
- if (router.isBuilt()) {
77
- return router;
78
- }
79
-
80
- const useBefore = getValue(provider, "middlewares.useBefore", []);
81
- const middlewares: any[] = [...parentMiddlewares, ...useBefore];
82
- const {children} = provider;
83
-
84
- // Set default to true in next major version
85
- const appendChildrenRoutesFirst = constant<boolean>("router.appendChildrenRoutesFirst", false);
86
-
87
- if (appendChildrenRoutesFirst) {
88
- children.forEach((token: Type<any>) => {
89
- const nested = this.from(token, middlewares);
90
- router.use(nested);
91
- });
92
- }
93
-
94
- getOperationsRoutes(provider.token, {allowedVerbs: this.allowedVerbs}).forEach((operationRoute) => {
95
- const {endpoint} = operationRoute;
96
- const {beforeMiddlewares, middlewares: mldwrs, afterMiddlewares} = endpoint;
97
-
98
- const useBefore = getValue(provider, "middlewares.useBefore", []);
99
- const use = getValue(provider, "middlewares.use", []);
100
- const useAfter = getValue(provider, "middlewares.useAfter", []);
101
-
102
- let handlers = this.hooks.alter<AlterEndpointHandlersArg>(
103
- "alterEndpointHandlers",
104
- {
105
- before: [...parentMiddlewares, ...useBefore, ...beforeMiddlewares, ...use, ...mldwrs],
106
- endpoint,
107
- after: [...afterMiddlewares, ...useAfter]
108
- },
109
- [operationRoute],
110
- this
111
- );
112
-
113
- handlers = this.sortHandlers(handlers);
114
-
115
- router.addRoute(
116
- operationRoute.method,
117
- operationRoute.path || "",
118
- [
119
- useContextHandler(($ctx) => {
120
- $ctx.endpoint = operationRoute.endpoint;
121
- }),
122
- ...[...handlers.before, handlers.endpoint, ...handlers.after]
123
- ],
124
- operationRoute
125
- );
126
- });
127
-
128
- if (!appendChildrenRoutesFirst) {
129
- children.forEach((token: Type<any>) => {
130
- const nested = this.from(token, middlewares);
131
- router.use(nested);
132
- });
133
- }
134
-
135
- return router;
136
- }
137
-
138
- getLayers(router: PlatformRouter): PlatformLayer[] {
139
- return this.flatMapLayers(router.layers);
140
- }
141
-
142
- private sortHandlers(handlers: AlterEndpointHandlersArg) {
143
- const get = (token: TokenProvider) => {
144
- return injector().getProvider(token)?.priority || 0;
145
- };
146
-
147
- const sort = (p1: TokenProvider, p2: TokenProvider) => (get(p1) < get(p2) ? -1 : get(p1) > get(p2) ? 1 : 0);
148
-
149
- handlers.before = handlers.before.sort(sort);
150
- handlers.after = handlers.after.sort(sort);
151
-
152
- return handlers;
153
- }
154
-
155
- private flatMapLayers(layers: PlatformLayer[]): PlatformLayer[] {
156
- return layers
157
- .flatMap((layer) => {
158
- if (layer.router) {
159
- return this.flatMapLayers(layer.layers).map((subLayer: PlatformLayer) => {
160
- return new PlatformLayer({
161
- ...subLayer,
162
- path: concatPath(layer.path, subLayer.path)
163
- });
164
- });
165
- }
166
-
167
- return new PlatformLayer(layer);
168
- })
169
- .map((layer) => {
170
- const handlers = layer.handlers.map((handlerMetadata) => {
171
- // set path on handler metadata to retrieve it later in $ctx
172
- handlerMetadata.path = layer.path;
173
-
174
- if (handlerMetadata.isRawFn()) {
175
- return handlerMetadata.handler;
176
- }
177
-
178
- return this.hooks.alter<PlatformHandlerMetadata, PlatformParamsCallback>("alterHandler", handlerMetadata);
179
- });
180
-
181
- layer.set(handlers);
182
-
183
- return layer;
184
- });
185
- }
186
- }
187
-
188
- injectable(PlatformRouters);
189
- /**
190
- * Create injectable router for the current invoked provider.
191
- * @ignore
192
- */
193
- $on(`$beforeInvoke:${ProviderType.CONTROLLER}`, ({provider, locals}: ResolvedInvokeOptions) => {
194
- const router = createInjectableRouter(provider as ControllerProvider);
195
- locals.set(PlatformRouter, router);
196
- });
@@ -1 +0,0 @@
1
- export type SinglePathType = string | RegExp;
package/src/index.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * @file Automatically generated by @tsed/barrels.
3
- */
4
- export * from "./domain/PlatformHandlerMetadata.js";
5
- export * from "./domain/PlatformHandlerType.js";
6
- export * from "./domain/PlatformLayer.js";
7
- export * from "./domain/PlatformRouter.js";
8
- export * from "./domain/PlatformRouters.js";
9
- export * from "./domain/SinglePathType.js";
10
- export * from "./utils/formatMethod.js";
11
- export * from "./utils/useContextHandler.js";
@@ -1,5 +0,0 @@
1
- import {OperationVerbs} from "@tsed/schema";
2
-
3
- export function formatMethod(method: string | undefined) {
4
- return (method === OperationVerbs.CUSTOM ? "use" : method || "use").toLowerCase();
5
- }
@@ -1,22 +0,0 @@
1
- import {DIContext} from "@tsed/di";
2
-
3
- import {PlatformHandlerType} from "../domain/PlatformHandlerType.js";
4
-
5
- export type PlatformContextHandler<Context = DIContext> = ($ctx: Context) => any | Promise<any>;
6
-
7
- /**
8
- * Create Ts.ED context handler
9
- * @param fn
10
- * @ignore
11
- */
12
- export function useContextHandler(fn: PlatformContextHandler & {type?: PlatformHandlerType}) {
13
- fn.type = PlatformHandlerType.CTX_FN;
14
-
15
- return fn;
16
- }
17
-
18
- export function useResponseHandler(fn: PlatformContextHandler & {type?: PlatformHandlerType}) {
19
- fn.type = PlatformHandlerType.RESPONSE_FN;
20
-
21
- return fn;
22
- }
package/vitest.config.mts DELETED
@@ -1,21 +0,0 @@
1
- // @ts-ignore
2
- import {presets} from "@tsed/vitest/presets";
3
- import {defineConfig} from "vitest/config";
4
-
5
- export default defineConfig(
6
- {
7
- ...presets,
8
- test: {
9
- ...presets.test,
10
- coverage: {
11
- ...presets.test.coverage,
12
- thresholds: {
13
- statements: 0,
14
- branches: 0,
15
- functions: 0,
16
- lines: 0
17
- }
18
- }
19
- }
20
- }
21
- );