@tsed/common 7.13.0 → 7.13.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.
|
@@ -15,7 +15,7 @@ let Platform = class Platform {
|
|
|
15
15
|
injector;
|
|
16
16
|
platformApplication;
|
|
17
17
|
platformRouters;
|
|
18
|
-
#
|
|
18
|
+
#layers;
|
|
19
19
|
constructor(injector, platformApplication, platformRouters) {
|
|
20
20
|
this.injector = injector;
|
|
21
21
|
this.platformApplication = platformApplication;
|
|
@@ -40,23 +40,24 @@ let Platform = class Platform {
|
|
|
40
40
|
return this;
|
|
41
41
|
}
|
|
42
42
|
getLayers() {
|
|
43
|
-
this.#
|
|
44
|
-
return this
|
|
45
|
-
if (layer.isProvider()) {
|
|
46
|
-
this.#controllers.set(layer.provider.token, {
|
|
47
|
-
route: String(layer.path).split(layer.provider.path)[0],
|
|
48
|
-
provider: layer.provider
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return layer;
|
|
52
|
-
});
|
|
43
|
+
this.#layers = this.#layers || this.platformRouters.getLayers(this.app);
|
|
44
|
+
return this.#layers;
|
|
53
45
|
}
|
|
54
46
|
/**
|
|
55
47
|
* Get all controllers mounted on the application.
|
|
56
48
|
* @returns {RouteController[]}
|
|
57
49
|
*/
|
|
58
50
|
getMountedControllers() {
|
|
59
|
-
|
|
51
|
+
const controllers = this.getLayers().reduce((controllers, layer) => {
|
|
52
|
+
if (layer.isProvider()) {
|
|
53
|
+
controllers.set(layer.provider.token, {
|
|
54
|
+
route: String(layer.getBasePath()),
|
|
55
|
+
provider: layer.provider
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return controllers;
|
|
59
|
+
}, new Map());
|
|
60
|
+
return [...controllers.values()];
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
Platform = tslib_1.__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/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AAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAExE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;OAGG;IACI,qBAAqB;QAC1B,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,EAAE;YACjE,IAAI,KAAK,CAAC,UAAU,EAAE,EAAE;gBACtB,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE;oBACpC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;oBAClC,QAAQ,EAAE,KAAK,CAAC,QAAQ;iBACzB,CAAC,CAAC;aACJ;YAED,OAAO,WAAW,CAAC;QACrB,CAAC,EAAE,IAAI,GAAG,EAA2B,CAAC,CAAC;QAEvC,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;AA3DY,QAAQ;IAJpB,IAAA,eAAU,EAAC;QACV,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,iCAAe,CAAC;KAC3B,CAAC;6CAKqB,oBAAe;QACJ,yCAAmB;QACvB,iCAAe;GANhC,QAAQ,CA2DpB;AA3DY,4BAAQ","sourcesContent":["import {ControllerProvider, Injectable, InjectorService, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {PlatformLayer, PlatformRouters} from \"@tsed/platform-router\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformHandler} from \"./PlatformHandler\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformHandler]\n})\nexport class Platform {\n #layers: PlatformLayer[];\n\n constructor(\n readonly injector: InjectorService,\n readonly platformApplication: PlatformApplication,\n readonly platformRouters: PlatformRouters\n ) {\n platformRouters.prebuild();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(route: string, token: TokenProvider) {\n const provider = this.injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return this;\n }\n\n const router = this.platformRouters.from(provider.token);\n\n this.app.use(route, router);\n\n return this;\n }\n\n public getLayers() {\n this.#layers = this.#layers || this.platformRouters.getLayers(this.app);\n\n return this.#layers;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers() {\n const controllers = this.getLayers().reduce((controllers, layer) => {\n if (layer.isProvider()) {\n controllers.set(layer.provider.token, {\n route: String(layer.getBasePath()),\n provider: layer.provider\n });\n }\n\n return controllers;\n }, new Map<string, RouteController>());\n\n return [...controllers.values()];\n }\n}\n"]}
|
|
@@ -12,7 +12,7 @@ let Platform = class Platform {
|
|
|
12
12
|
injector;
|
|
13
13
|
platformApplication;
|
|
14
14
|
platformRouters;
|
|
15
|
-
#
|
|
15
|
+
#layers;
|
|
16
16
|
constructor(injector, platformApplication, platformRouters) {
|
|
17
17
|
this.injector = injector;
|
|
18
18
|
this.platformApplication = platformApplication;
|
|
@@ -37,23 +37,24 @@ let Platform = class Platform {
|
|
|
37
37
|
return this;
|
|
38
38
|
}
|
|
39
39
|
getLayers() {
|
|
40
|
-
this.#
|
|
41
|
-
return this
|
|
42
|
-
if (layer.isProvider()) {
|
|
43
|
-
this.#controllers.set(layer.provider.token, {
|
|
44
|
-
route: String(layer.path).split(layer.provider.path)[0],
|
|
45
|
-
provider: layer.provider
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
return layer;
|
|
49
|
-
});
|
|
40
|
+
this.#layers = this.#layers || this.platformRouters.getLayers(this.app);
|
|
41
|
+
return this.#layers;
|
|
50
42
|
}
|
|
51
43
|
/**
|
|
52
44
|
* Get all controllers mounted on the application.
|
|
53
45
|
* @returns {RouteController[]}
|
|
54
46
|
*/
|
|
55
47
|
getMountedControllers() {
|
|
56
|
-
|
|
48
|
+
const controllers = this.getLayers().reduce((controllers, layer) => {
|
|
49
|
+
if (layer.isProvider()) {
|
|
50
|
+
controllers.set(layer.provider.token, {
|
|
51
|
+
route: String(layer.getBasePath()),
|
|
52
|
+
provider: layer.provider
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return controllers;
|
|
56
|
+
}, new Map());
|
|
57
|
+
return [...controllers.values()];
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
Platform = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAE,eAAe,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACvG,OAAO,
|
|
1
|
+
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAE,eAAe,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACvG,OAAO,EAAgB,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;GAIG;AAKH,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAIR;IACA;IACA;IALX,OAAO,CAAkB;IAEzB,YACW,QAAyB,EACzB,mBAAwC,EACxC,eAAgC;QAFhC,aAAQ,GAAR,QAAQ,CAAiB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,oBAAe,GAAf,eAAe,CAAiB;QAEzC,eAAe,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,C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IAAI,GAAG,EAA2B,CAAC,CAAC;QAEvC,OAAO,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;CACF,CAAA;AA3DY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,eAAe,CAAC;KAC3B,CAAC;qCAKqB,eAAe;QACJ,mBAAmB;QACvB,eAAe;GANhC,QAAQ,CA2DpB;SA3DY,QAAQ","sourcesContent":["import {ControllerProvider, Injectable, InjectorService, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {PlatformLayer, PlatformRouters} from \"@tsed/platform-router\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformHandler} from \"./PlatformHandler\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformHandler]\n})\nexport class Platform {\n #layers: PlatformLayer[];\n\n constructor(\n readonly injector: InjectorService,\n readonly platformApplication: PlatformApplication,\n readonly platformRouters: PlatformRouters\n ) {\n platformRouters.prebuild();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(route: string, token: TokenProvider) {\n const provider = this.injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return this;\n }\n\n const router = this.platformRouters.from(provider.token);\n\n this.app.use(route, router);\n\n return this;\n }\n\n public getLayers() {\n this.#layers = this.#layers || this.platformRouters.getLayers(this.app);\n\n return this.#layers;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers() {\n const controllers = this.getLayers().reduce((controllers, layer) => {\n if (layer.isProvider()) {\n controllers.set(layer.provider.token, {\n route: String(layer.getBasePath()),\n provider: layer.provider\n });\n }\n\n return controllers;\n }, new Map<string, RouteController>());\n\n return [...controllers.values()];\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InjectorService, TokenProvider } from "@tsed/di";
|
|
2
|
-
import { PlatformRouters } from "@tsed/platform-router";
|
|
2
|
+
import { PlatformLayer, PlatformRouters } from "@tsed/platform-router";
|
|
3
3
|
import { Route, RouteController } from "../interfaces/Route";
|
|
4
4
|
import { PlatformApplication } from "./PlatformApplication";
|
|
5
5
|
/**
|
|
@@ -16,7 +16,7 @@ export declare class Platform {
|
|
|
16
16
|
get app(): PlatformApplication<TsED.Application>;
|
|
17
17
|
addRoutes(routes: Route[]): void;
|
|
18
18
|
addRoute(route: string, token: TokenProvider): this;
|
|
19
|
-
getLayers():
|
|
19
|
+
getLayers(): PlatformLayer[];
|
|
20
20
|
/**
|
|
21
21
|
* Get all controllers mounted on the application.
|
|
22
22
|
* @returns {RouteController[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/common",
|
|
3
|
-
"version": "7.13.
|
|
3
|
+
"version": "7.13.1",
|
|
4
4
|
"description": "A TypeScript Framework on top of Express",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -62,21 +62,21 @@
|
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@tsed/core": "7.13.
|
|
66
|
-
"@tsed/di": "7.13.
|
|
67
|
-
"@tsed/exceptions": "7.13.
|
|
68
|
-
"@tsed/json-mapper": "7.13.
|
|
65
|
+
"@tsed/core": "7.13.1",
|
|
66
|
+
"@tsed/di": "7.13.1",
|
|
67
|
+
"@tsed/exceptions": "7.13.1",
|
|
68
|
+
"@tsed/json-mapper": "7.13.1",
|
|
69
69
|
"@tsed/logger": ">=6.2.2",
|
|
70
70
|
"@tsed/logger-file": ">=6.2.2",
|
|
71
|
-
"@tsed/perf": "7.13.
|
|
72
|
-
"@tsed/platform-exceptions": "7.13.
|
|
73
|
-
"@tsed/platform-log-middleware": "7.13.
|
|
74
|
-
"@tsed/platform-middlewares": "7.13.
|
|
75
|
-
"@tsed/platform-params": "7.13.
|
|
76
|
-
"@tsed/platform-response-filter": "7.13.
|
|
77
|
-
"@tsed/platform-router": "7.13.
|
|
78
|
-
"@tsed/platform-views": "7.13.
|
|
79
|
-
"@tsed/schema": "7.13.
|
|
71
|
+
"@tsed/perf": "7.13.1",
|
|
72
|
+
"@tsed/platform-exceptions": "7.13.1",
|
|
73
|
+
"@tsed/platform-log-middleware": "7.13.1",
|
|
74
|
+
"@tsed/platform-middlewares": "7.13.1",
|
|
75
|
+
"@tsed/platform-params": "7.13.1",
|
|
76
|
+
"@tsed/platform-response-filter": "7.13.1",
|
|
77
|
+
"@tsed/platform-router": "7.13.1",
|
|
78
|
+
"@tsed/platform-views": "7.13.1",
|
|
79
|
+
"@tsed/schema": "7.13.1",
|
|
80
80
|
"@types/json-schema": "7.0.11",
|
|
81
81
|
"tslib": "2.4.0",
|
|
82
82
|
"uuid": "8.3.2"
|