@tsed/common 7.0.0-beta.9 → 7.0.0-rc.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.
- package/coverage.json +6 -0
- package/jest.config.js +9 -0
- package/lib/cjs/builder/PlatformBuilder.js +86 -68
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +0 -64
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/cjs/decorators/params/error.js +1 -1
- package/lib/cjs/decorators/params/error.js.map +1 -1
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/cjs/domain/PlatformContext.js +46 -38
- package/lib/cjs/domain/PlatformContext.js.map +1 -1
- package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/cjs/exports.js +1 -1
- package/lib/cjs/exports.js.map +1 -1
- package/lib/cjs/index.js +1 -9
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/cjs/interfaces/Route.js.map +1 -1
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +2 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/cjs/services/FakeAdapter.js +6 -12
- package/lib/cjs/services/FakeAdapter.js.map +1 -1
- package/lib/cjs/services/Platform.js +30 -86
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +10 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -1
- package/lib/cjs/services/PlatformApplication.js +23 -9
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformHandler.js +112 -171
- package/lib/cjs/services/PlatformHandler.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +5 -19
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +16 -12
- package/lib/cjs/services/PlatformRequest.js.map +1 -1
- package/lib/cjs/services/PlatformResponse.js +19 -22
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +29 -9
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/createContext.js +32 -21
- package/lib/cjs/utils/createContext.js.map +1 -1
- package/lib/cjs/utils/createHttpServer.js +3 -3
- package/lib/cjs/utils/createHttpServer.js.map +1 -1
- package/lib/cjs/utils/createHttpsServer.js +3 -3
- package/lib/cjs/utils/createHttpsServer.js.map +1 -1
- package/lib/cjs/utils/createInjector.js +6 -8
- package/lib/cjs/utils/createInjector.js.map +1 -1
- package/lib/cjs/utils/ensureContext.js +16 -0
- package/lib/cjs/utils/ensureContext.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +6 -12
- package/lib/cjs/utils/getConfiguration.js.map +1 -1
- package/lib/cjs/utils/printRoutes.js +10 -8
- package/lib/cjs/utils/printRoutes.js.map +1 -1
- package/lib/cjs/utils/setResponseHeaders.js +8 -14
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
- package/lib/esm/builder/PlatformBuilder.js +63 -68
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/esm/config/services/PlatformConfiguration.js +0 -64
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/esm/decorators/params/error.js +1 -1
- package/lib/esm/decorators/params/error.js.map +1 -1
- package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/esm/domain/PlatformContext.js +46 -38
- package/lib/esm/domain/PlatformContext.js.map +1 -1
- package/lib/esm/domain/PlatformRouteDetails.js +1 -19
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/esm/exports.js +1 -1
- package/lib/esm/exports.js.map +1 -1
- package/lib/esm/index.js +1 -9
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/esm/interfaces/Route.js.map +1 -1
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +2 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/services/FakeAdapter.js +6 -12
- package/lib/esm/services/FakeAdapter.js.map +1 -1
- package/lib/esm/services/Platform.js +31 -87
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +10 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -1
- package/lib/esm/services/PlatformApplication.js +23 -9
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformHandler.js +114 -173
- package/lib/esm/services/PlatformHandler.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +5 -19
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/services/PlatformRequest.js +16 -12
- package/lib/esm/services/PlatformRequest.js.map +1 -1
- package/lib/esm/services/PlatformResponse.js +19 -22
- package/lib/esm/services/PlatformResponse.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +29 -9
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createContext.js +30 -20
- package/lib/esm/utils/createContext.js.map +1 -1
- package/lib/esm/utils/createHttpServer.js +3 -3
- package/lib/esm/utils/createHttpServer.js.map +1 -1
- package/lib/esm/utils/createHttpsServer.js +3 -3
- package/lib/esm/utils/createHttpsServer.js.map +1 -1
- package/lib/esm/utils/createInjector.js +7 -9
- package/lib/esm/utils/createInjector.js.map +1 -1
- package/lib/esm/utils/ensureContext.js +12 -0
- package/lib/esm/utils/ensureContext.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +8 -14
- package/lib/esm/utils/getConfiguration.js.map +1 -1
- package/lib/esm/utils/printRoutes.js +10 -8
- package/lib/esm/utils/printRoutes.js.map +1 -1
- package/lib/esm/utils/setResponseHeaders.js +8 -14
- package/lib/esm/utils/setResponseHeaders.js.map +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +17 -16
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
- package/lib/types/config/services/PlatformConfiguration.d.ts +6 -22
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
- package/lib/types/domain/PlatformContext.d.ts +32 -18
- package/lib/types/domain/PlatformRouteDetails.d.ts +4 -19
- package/lib/types/exports.d.ts +1 -1
- package/lib/types/index.d.ts +1 -9
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +0 -1
- package/lib/types/interfaces/Route.d.ts +2 -3
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +1 -1
- package/lib/types/services/FakeAdapter.d.ts +7 -6
- package/lib/types/services/Platform.d.ts +7 -28
- package/lib/types/services/PlatformAdapter.d.ts +22 -11
- package/lib/types/services/PlatformApplication.d.ts +14 -6
- package/lib/types/services/PlatformHandler.d.ts +21 -59
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +1 -2
- package/lib/types/services/PlatformRequest.d.ts +8 -10
- package/lib/types/services/PlatformResponse.d.ts +11 -15
- package/lib/types/services/PlatformTest.d.ts +4 -3
- package/lib/types/utils/createContext.d.ts +4 -1
- package/lib/types/utils/createHttpsServer.d.ts +1 -0
- package/lib/types/utils/createInjector.d.ts +2 -2
- package/lib/types/utils/ensureContext.d.ts +2 -0
- package/lib/types/utils/listenServer.d.ts +2 -0
- package/package.json +27 -25
- package/readme.md +2 -1
- package/lib/cjs/builder/PlatformControllerBuilder.js +0 -82
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +0 -3
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
- package/lib/cjs/domain/ControllerProvider.js +0 -51
- package/lib/cjs/domain/ControllerProvider.js.map +0 -1
- package/lib/cjs/domain/HandlerMetadata.js +0 -57
- package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
- package/lib/cjs/services/PlatformRouter.js +0 -108
- package/lib/cjs/services/PlatformRouter.js.map +0 -1
- package/lib/cjs/utils/__mock__/Test1.js +0 -8
- package/lib/cjs/utils/__mock__/Test1.js.map +0 -1
- package/lib/cjs/utils/__mock__/Test2.js +0 -8
- package/lib/cjs/utils/__mock__/Test2.js.map +0 -1
- package/lib/cjs/utils/createHandlerMetadata.js +0 -49
- package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
- package/lib/cjs/utils/importProviders.js +0 -29
- package/lib/cjs/utils/importProviders.js.map +0 -1
- package/lib/cjs/utils/useCtxHandler.js +0 -15
- package/lib/cjs/utils/useCtxHandler.js.map +0 -1
- package/lib/esm/builder/PlatformControllerBuilder.js +0 -76
- package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +0 -2
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
- package/lib/esm/domain/ControllerProvider.js +0 -47
- package/lib/esm/domain/ControllerProvider.js.map +0 -1
- package/lib/esm/domain/HandlerMetadata.js +0 -53
- package/lib/esm/domain/HandlerMetadata.js.map +0 -1
- package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
- package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
- package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
- package/lib/esm/services/PlatformRouter.js +0 -105
- package/lib/esm/services/PlatformRouter.js.map +0 -1
- package/lib/esm/utils/__mock__/Test1.js +0 -4
- package/lib/esm/utils/__mock__/Test1.js.map +0 -1
- package/lib/esm/utils/__mock__/Test2.js +0 -4
- package/lib/esm/utils/__mock__/Test2.js.map +0 -1
- package/lib/esm/utils/createHandlerMetadata.js +0 -45
- package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
- package/lib/esm/utils/importProviders.js +0 -25
- package/lib/esm/utils/importProviders.js.map +0 -1
- package/lib/esm/utils/useCtxHandler.js +0 -11
- package/lib/esm/utils/useCtxHandler.js.map +0 -1
- package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -18
- package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
- package/lib/types/domain/ControllerProvider.d.ts +0 -24
- package/lib/types/domain/HandlerMetadata.d.ts +0 -32
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -6
- package/lib/types/services/PlatformRouter.d.ts +0 -51
- package/lib/types/utils/__mock__/Test1.d.ts +0 -3
- package/lib/types/utils/__mock__/Test2.d.ts +0 -3
- package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
- package/lib/types/utils/importProviders.d.ts +0 -10
- package/lib/types/utils/useCtxHandler.d.ts +0 -13
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureContext.js","sourceRoot":"","sources":["../../../src/utils/ensureContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,MAAM,UAAU,aAAa,CAAC,OAAY,EAAE,EAAkC,EAAE,QAAqB;IACnG,MAAM,IAAI,GAAG,UAAU,EAAmB,CAAC;IAE3C,IAAI,IAAI,EAAE;QACR,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;KACjB;IAED,IAAI,CAAC,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE;QAC9B,OAAO,QAAQ,EAAE,CAAC;KACnB;IAED,OAAO,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAC3D,CAAC","sourcesContent":["import {getContext} from \"@tsed/di\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\n\nexport function ensureContext(request: any, cb: ($ctx: PlatformContext) => any, fallback?: () => void) {\n const $ctx = getContext<PlatformContext>();\n\n if ($ctx) {\n return cb($ctx);\n }\n\n if (!request?.$ctx && fallback) {\n return fallback();\n }\n\n return request.$ctx.runInContext(() => cb(request.$ctx));\n}\n"]}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ProviderScope, ProviderType } from "@tsed/di";
|
|
1
|
+
import { Env, Store } from "@tsed/core";
|
|
2
|
+
import { mergeMount, ProviderScope, ProviderType } from "@tsed/di";
|
|
3
3
|
export function getConfiguration(configuration = {}, module = null) {
|
|
4
|
+
if (configuration.$$resolved) {
|
|
5
|
+
return configuration;
|
|
6
|
+
}
|
|
4
7
|
const store = module ? Store.from(module).get("configuration") || {} : {};
|
|
5
8
|
const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
|
|
9
|
+
return {
|
|
10
|
+
$$resolved: true,
|
|
9
11
|
env,
|
|
10
12
|
httpPort: 8080,
|
|
11
13
|
httpsPort: false,
|
|
@@ -16,11 +18,7 @@ export function getConfiguration(configuration = {}, module = null) {
|
|
|
16
18
|
...store.scopes,
|
|
17
19
|
...configuration.scopes
|
|
18
20
|
},
|
|
19
|
-
mount: store.mount
|
|
20
|
-
? deepMerge(store.mount || {}, configuration.mount || {})
|
|
21
|
-
: {
|
|
22
|
-
"/rest": "${rootDir}/controllers/**/*.ts"
|
|
23
|
-
},
|
|
21
|
+
mount: mergeMount(store.mount, configuration.mount),
|
|
24
22
|
logger: {
|
|
25
23
|
debug: false,
|
|
26
24
|
level: env === Env.TEST ? "off" : "info",
|
|
@@ -30,9 +28,5 @@ export function getConfiguration(configuration = {}, module = null) {
|
|
|
30
28
|
jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
|
|
31
29
|
}
|
|
32
30
|
};
|
|
33
|
-
if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
|
|
34
|
-
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
35
|
-
}
|
|
36
|
-
return config;
|
|
37
31
|
}
|
|
38
32
|
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAE,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAEjE,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,IAAI,aAAa,CAAC,UAAU,EAAE;QAC5B,OAAO,aAAa,CAAC;KACtB;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEvF,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EAAE,UAAU,CAAC,KAAK,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;QACnD,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import {Env, Store, Type} from \"@tsed/core\";\nimport {mergeMount, ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n if (configuration.$$resolved) {\n return configuration;\n }\n\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n return {\n $$resolved: true,\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount: mergeMount(store.mount, configuration.mount),\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n}\n"]}
|
|
@@ -6,18 +6,20 @@ export function printRoutes(routes) {
|
|
|
6
6
|
PUT: "blue",
|
|
7
7
|
DELETE: "red",
|
|
8
8
|
PATCH: "magenta",
|
|
9
|
-
ALL: "cyan"
|
|
9
|
+
ALL: "cyan",
|
|
10
|
+
STATICS: "white"
|
|
10
11
|
};
|
|
11
12
|
const list = routes.map((route) => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
const method = route.method.toUpperCase();
|
|
14
|
+
return {
|
|
15
|
+
...route,
|
|
16
|
+
method: {
|
|
17
|
+
length: method.length,
|
|
18
|
+
toString: () => {
|
|
19
|
+
return colorize(method, mapColor[method]);
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
};
|
|
20
|
-
return obj;
|
|
21
23
|
});
|
|
22
24
|
const str = $log.drawTable(list, {
|
|
23
25
|
padding: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;QACX,OAAO,EAAE,OAAO;KACjB,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAE1C,OAAO;YACL,GAAG,KAAK;YACR,MAAM,EAAE;gBACN,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,QAAQ,EAAE,GAAG,EAAE;oBACb,OAAO,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;gBAC5C,CAAC;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\",\n STATICS: \"white\"\n };\n\n const list = routes.map((route) => {\n const method = route.method.toUpperCase();\n\n return {\n ...route,\n method: {\n length: method.length,\n toString: () => {\n return colorize(method, mapColor[method]);\n }\n }\n };\n });\n\n const str = $log.drawTable(list, {\n padding: 1,\n header: {\n method: \"Method\",\n url: \"Endpoint\",\n name: \"Class method\"\n }\n });\n\n return \"\\n\" + str.trim();\n}\n"]}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
function mergeHeaders(specHeaders, headers) {
|
|
2
|
-
return Object.entries(specHeaders).reduce((headers, [key, item]) => {
|
|
3
|
-
key = key.toLowerCase();
|
|
4
|
-
return {
|
|
5
|
-
...headers,
|
|
6
|
-
[key]: headers[key] === undefined ? String(item.example) : headers[key]
|
|
7
|
-
};
|
|
8
|
-
}, headers);
|
|
9
|
-
}
|
|
10
1
|
/**
|
|
11
2
|
* @ignore
|
|
12
3
|
*/
|
|
13
4
|
export function setResponseHeaders(ctx) {
|
|
14
5
|
const { response, endpoint } = ctx;
|
|
15
6
|
const { operation } = endpoint;
|
|
16
|
-
if (
|
|
7
|
+
if (ctx.isDone()) {
|
|
17
8
|
return;
|
|
18
9
|
}
|
|
19
10
|
if (!response.hasStatus()) {
|
|
@@ -21,11 +12,14 @@ export function setResponseHeaders(ctx) {
|
|
|
21
12
|
response.status(operation.getStatus());
|
|
22
13
|
}
|
|
23
14
|
const statusCode = response.statusCode;
|
|
24
|
-
const headers = operation.getHeadersOf(
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const headers = operation.getHeadersOf(statusCode);
|
|
16
|
+
Object.entries(headers).forEach(([key, item]) => {
|
|
17
|
+
if (!response.get(key)) {
|
|
18
|
+
response.setHeader(key, String(item.example));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
27
21
|
if (operation.isRedirection(statusCode)) {
|
|
28
|
-
response.redirect(statusCode,
|
|
22
|
+
response.redirect(statusCode, response.get("location"));
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
25
|
//# sourceMappingURL=setResponseHeaders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":"
|
|
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,CAAQ,EAAE,EAAE;QACrD,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]: any[]) => {\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,25 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService, ProviderOpts } from "@tsed/di";
|
|
4
|
-
import {
|
|
5
|
-
import { PlatformApplication } from "../services/PlatformApplication";
|
|
3
|
+
import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
|
|
4
|
+
import { PlatformLayer } from "@tsed/platform-router";
|
|
6
5
|
import type { IncomingMessage, ServerResponse } from "http";
|
|
6
|
+
import { Platform } from "../services/Platform";
|
|
7
7
|
import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
|
|
8
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
8
9
|
/**
|
|
9
10
|
* @platform
|
|
10
11
|
*/
|
|
11
|
-
export declare class PlatformBuilder<App = TsED.Application
|
|
12
|
+
export declare class PlatformBuilder<App = TsED.Application> {
|
|
12
13
|
#private;
|
|
13
|
-
static adapter: Type<PlatformAdapter<any
|
|
14
|
+
static adapter: Type<PlatformAdapter<any>>;
|
|
14
15
|
readonly name: string;
|
|
15
16
|
protected startedAt: Date;
|
|
16
17
|
protected current: Date;
|
|
17
|
-
protected constructor(adapter: Type<PlatformAdapter<App
|
|
18
|
+
protected constructor(adapter: Type<PlatformAdapter<App>> | undefined, module: Type, settings: Partial<TsED.Configuration>);
|
|
18
19
|
get injector(): InjectorService;
|
|
19
20
|
get rootModule(): any;
|
|
20
|
-
get app(): PlatformApplication<App
|
|
21
|
+
get app(): PlatformApplication<App>;
|
|
21
22
|
get platform(): Platform;
|
|
22
|
-
get adapter(): PlatformAdapter<App
|
|
23
|
+
get adapter(): PlatformAdapter<App>;
|
|
23
24
|
/**
|
|
24
25
|
* Return the settings configured by the decorator @@Configuration@@.
|
|
25
26
|
*
|
|
@@ -41,17 +42,17 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
41
42
|
*
|
|
42
43
|
* @returns {PlatformConfiguration}
|
|
43
44
|
*/
|
|
44
|
-
get settings():
|
|
45
|
+
get settings(): import("@tsed/di").DIConfiguration;
|
|
45
46
|
get logger(): import("@tsed/di").DILogger;
|
|
46
47
|
get disableBootstrapLog(): any;
|
|
47
|
-
static create<App = TsED.Application
|
|
48
|
-
static build<App = TsED.Application
|
|
48
|
+
static create<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
49
|
+
static build<App = TsED.Application>(module: Type<any>, { adapter, ...settings }: PlatformBuilderSettings<App>): PlatformBuilder<App>;
|
|
49
50
|
/**
|
|
50
51
|
* Bootstrap a server application
|
|
51
52
|
* @param module
|
|
52
53
|
* @param settings
|
|
53
54
|
*/
|
|
54
|
-
static bootstrap<App = TsED.Application
|
|
55
|
+
static bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
|
|
55
56
|
callback(): (req: IncomingMessage, res: ServerResponse) => void;
|
|
56
57
|
callback(req: IncomingMessage, res: ServerResponse): void;
|
|
57
58
|
log(...data: any[]): any;
|
|
@@ -59,7 +60,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
59
60
|
* Add classes to the components list
|
|
60
61
|
* @param classes
|
|
61
62
|
*/
|
|
62
|
-
addComponents(classes:
|
|
63
|
+
addComponents(classes: Type | Type[]): this;
|
|
63
64
|
/**
|
|
64
65
|
* Add classes decorated by @@Controller@@ to components container.
|
|
65
66
|
*
|
|
@@ -80,7 +81,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
80
81
|
* @param {string} endpoint
|
|
81
82
|
* @param {any[]} controllers
|
|
82
83
|
*/
|
|
83
|
-
addControllers(endpoint: string, controllers:
|
|
84
|
+
addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]): void;
|
|
84
85
|
runLifecycle(): Promise<this>;
|
|
85
86
|
loadInjector(): Promise<void>;
|
|
86
87
|
listen(network?: boolean): Promise<void>;
|
|
@@ -91,8 +92,8 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
91
92
|
useProvider(token: Type<any>, settings?: Partial<ProviderOpts>): this;
|
|
92
93
|
bootstrap(): Promise<this>;
|
|
93
94
|
protected loadRoutes(): Promise<void>;
|
|
95
|
+
protected mapRouters(): Promise<void>;
|
|
94
96
|
protected diff(): string;
|
|
95
|
-
protected importProviders(): Promise<void>;
|
|
96
97
|
/**
|
|
97
98
|
* Load middlewares from configuration for the given hook
|
|
98
99
|
* @param hook
|
|
@@ -101,5 +102,5 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
101
102
|
protected loadMiddlewaresFor(hook: string): void;
|
|
102
103
|
protected createHttpServers(): void;
|
|
103
104
|
protected listenServers(): Promise<void>;
|
|
104
|
-
protected logRoutes(): Promise<void>;
|
|
105
|
+
protected logRoutes(layers: PlatformLayer[]): Promise<void>;
|
|
105
106
|
}
|
|
@@ -1,44 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* Enable debug mode. By default debug is false.
|
|
4
|
-
*/
|
|
5
|
-
debug?: boolean;
|
|
6
|
-
/**
|
|
7
|
-
* Enable info mode. By default debug is false.
|
|
8
|
-
*/
|
|
9
|
-
level?: "debug" | "info" | "warn" | "error" | "off";
|
|
10
|
-
/**
|
|
11
|
-
* Enable log performance tracker and disable log server.
|
|
12
|
-
*/
|
|
13
|
-
perf?: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* List of regexp to ignore log.
|
|
16
|
-
*/
|
|
17
|
-
ignoreUrlPatterns?: string[];
|
|
18
|
-
/**
|
|
19
|
-
* The number of space characters to use as white space in JSON output. Default is 2 (0 in production).
|
|
20
|
-
*/
|
|
21
|
-
jsonIndentation?: number;
|
|
22
|
-
/**
|
|
23
|
-
* A function called for each incoming request to create a request id.
|
|
24
|
-
* @returns {number}
|
|
25
|
-
*/
|
|
26
|
-
reqIdBuilder?: (req: TsED.Request) => string;
|
|
27
|
-
/**
|
|
28
|
-
* Disable routes table displayed in the logger. By default debug is `false`.
|
|
29
|
-
*/
|
|
30
|
-
disableRoutesSummary?: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Disable bootstrap log displayed in the logger. By default debug is `false`.
|
|
33
|
-
*/
|
|
34
|
-
disableBootstrapLog?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
* Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).
|
|
37
|
-
*/
|
|
38
|
-
format?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.
|
|
41
|
-
* Default size is set to 30.
|
|
42
|
-
*/
|
|
43
|
-
maxStackSize?: number;
|
|
1
|
+
import { DILoggerOptions } from "@tsed/di";
|
|
2
|
+
export interface PlatformLoggerSettings extends DILoggerOptions {
|
|
44
3
|
}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import { DIConfiguration } from "@tsed/di";
|
|
2
|
+
import { getHostInfoFromPort } from "@tsed/core";
|
|
3
|
+
import { DIConfiguration, TokenProvider } from "@tsed/di";
|
|
4
4
|
import Https from "https";
|
|
5
5
|
import { ConverterSettings } from "../interfaces/ConverterSettings";
|
|
6
|
-
import { EndpointDirectoriesSettings } from "../interfaces/EndpointDirectoriesSettings";
|
|
7
|
-
import { PlatformLoggerSettings } from "../interfaces/PlatformLoggerSettings";
|
|
8
6
|
/**
|
|
9
7
|
* `PlatformConfiguration` contains all information about your Server configuration.
|
|
10
8
|
*/
|
|
11
9
|
export declare class PlatformConfiguration extends DIConfiguration {
|
|
12
10
|
constructor();
|
|
13
|
-
get version(): string;
|
|
14
|
-
set version(v: string);
|
|
15
|
-
get rootDir(): string;
|
|
16
|
-
set rootDir(value: string);
|
|
17
11
|
get port(): string | number | false;
|
|
18
12
|
set port(value: string | number | false);
|
|
19
13
|
get httpsOptions(): Https.ServerOptions;
|
|
@@ -22,24 +16,14 @@ export declare class PlatformConfiguration extends DIConfiguration {
|
|
|
22
16
|
set httpPort(value: string | number | false);
|
|
23
17
|
get httpsPort(): string | number | false;
|
|
24
18
|
set httpsPort(value: string | number | false);
|
|
25
|
-
get
|
|
26
|
-
set
|
|
27
|
-
get
|
|
28
|
-
set
|
|
29
|
-
get componentsScan(): string[];
|
|
30
|
-
set componentsScan(value: string[]);
|
|
31
|
-
get statics(): EndpointDirectoriesSettings;
|
|
32
|
-
set statics(value: EndpointDirectoriesSettings);
|
|
19
|
+
get mount(): Record<string, TokenProvider[]>;
|
|
20
|
+
set mount(value: Record<string, TokenProvider[]>);
|
|
21
|
+
get statics(): Record<string, (any | string)[]>;
|
|
22
|
+
set statics(value: Record<string, (any | string)[]>);
|
|
33
23
|
get acceptMimes(): string[];
|
|
34
24
|
set acceptMimes(value: string[]);
|
|
35
|
-
get debug(): boolean;
|
|
36
|
-
set debug(debug: boolean);
|
|
37
25
|
get converter(): Partial<ConverterSettings>;
|
|
38
26
|
set converter(options: Partial<ConverterSettings>);
|
|
39
|
-
get logger(): Partial<PlatformLoggerSettings>;
|
|
40
|
-
set logger(value: Partial<PlatformLoggerSettings>);
|
|
41
|
-
get exclude(): string[];
|
|
42
|
-
set exclude(exclude: string[]);
|
|
43
27
|
get additionalProperties(): boolean;
|
|
44
28
|
/**
|
|
45
29
|
*
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import { AnyPromiseResult, AnyToPromise } from "@tsed/core";
|
|
2
2
|
import { PlatformContext } from "./PlatformContext";
|
|
3
|
-
/**
|
|
4
|
-
* @ignore
|
|
5
|
-
*/
|
|
6
|
-
export interface HandlerContextOptions {
|
|
7
|
-
$ctx: PlatformContext;
|
|
8
|
-
err?: any;
|
|
9
|
-
}
|
|
10
3
|
export declare class AnyToPromiseWithCtx extends AnyToPromise {
|
|
11
4
|
$ctx: PlatformContext;
|
|
12
|
-
|
|
13
|
-
constructor({ $ctx, err }: HandlerContextOptions);
|
|
5
|
+
constructor($ctx: PlatformContext);
|
|
14
6
|
isDone(): boolean;
|
|
15
7
|
call(cb: Function): Promise<AnyPromiseResult<any>>;
|
|
16
8
|
destroy(): void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { DIContext, DIContextOptions } from "@tsed/di";
|
|
3
|
+
import { PlatformHandlerMetadata } from "@tsed/platform-router";
|
|
4
4
|
import { EndpointMetadata } from "@tsed/schema";
|
|
5
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
6
|
+
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
5
7
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
8
|
import { PlatformRequest } from "../services/PlatformRequest";
|
|
7
9
|
import { PlatformResponse } from "../services/PlatformResponse";
|
|
@@ -12,36 +14,48 @@ declare global {
|
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
export interface PlatformContextOptions extends DIContextOptions {
|
|
15
|
-
event:
|
|
16
|
-
response?: ServerResponse;
|
|
17
|
-
request?: IncomingMessage;
|
|
18
|
-
};
|
|
17
|
+
event: IncomingEvent;
|
|
19
18
|
ignoreUrlPatterns?: any[];
|
|
20
19
|
endpoint?: EndpointMetadata;
|
|
21
20
|
}
|
|
22
|
-
export declare class PlatformContext extends
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
endpoint: EndpointMetadata;
|
|
21
|
+
export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext {
|
|
22
|
+
#private;
|
|
23
|
+
event: IncomingEvent;
|
|
27
24
|
/**
|
|
28
25
|
* The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
29
26
|
*/
|
|
30
27
|
data: any;
|
|
28
|
+
/**
|
|
29
|
+
* The error caught by the current handler
|
|
30
|
+
*/
|
|
31
|
+
error?: unknown;
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
next?: any;
|
|
31
36
|
/**
|
|
32
37
|
* The current @@PlatformResponse@@.
|
|
33
38
|
*/
|
|
34
|
-
response:
|
|
39
|
+
readonly response: PRes;
|
|
35
40
|
/**
|
|
36
41
|
* The current @@PlatformRequest@@.
|
|
37
42
|
*/
|
|
38
|
-
request:
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
readonly request: PReq;
|
|
44
|
+
/**
|
|
45
|
+
* The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
|
|
46
|
+
*/
|
|
47
|
+
endpoint: EndpointMetadata;
|
|
48
|
+
/**
|
|
49
|
+
* The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
|
|
50
|
+
*/
|
|
51
|
+
handlerMetadata: PlatformHandlerMetadata;
|
|
52
|
+
constructor(options: PlatformContextOptions);
|
|
41
53
|
get url(): string;
|
|
42
|
-
get app(): PlatformApplication<TsED.Application
|
|
43
|
-
|
|
44
|
-
|
|
54
|
+
get app(): PlatformApplication<TsED.Application>;
|
|
55
|
+
start(): Promise<void>;
|
|
56
|
+
finish(): Promise<void>;
|
|
57
|
+
isFinished(): boolean;
|
|
58
|
+
isDone(): any;
|
|
45
59
|
/**
|
|
46
60
|
* Return the framework request instance (Express, Koa, etc...)
|
|
47
61
|
*/
|
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
import { ControllerProvider } from "./ControllerProvider";
|
|
3
|
-
export interface PlatformRouterDetailsOptions {
|
|
4
|
-
provider: ControllerProvider;
|
|
5
|
-
endpoint: EndpointMetadata;
|
|
1
|
+
export interface PlatformRouteDetails {
|
|
6
2
|
method: string;
|
|
3
|
+
name: string;
|
|
7
4
|
url: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
readonly rawBody: boolean;
|
|
11
|
-
readonly provider: ControllerProvider;
|
|
12
|
-
constructor(options?: Partial<PlatformRouteDetails>);
|
|
13
|
-
toJSON(): {
|
|
14
|
-
method: string;
|
|
15
|
-
name: string;
|
|
16
|
-
url: string;
|
|
17
|
-
className: string;
|
|
18
|
-
methodClassName: string;
|
|
19
|
-
parameters: import("@tsed/schema").JsonParameterStore[];
|
|
20
|
-
rawBody: boolean;
|
|
21
|
-
};
|
|
5
|
+
className: string;
|
|
6
|
+
methodClassName: string;
|
|
22
7
|
}
|
package/lib/types/exports.d.ts
CHANGED
|
@@ -4,9 +4,9 @@ export * from "@tsed/di";
|
|
|
4
4
|
export * from "@tsed/platform-params";
|
|
5
5
|
export * from "@tsed/platform-exceptions";
|
|
6
6
|
export * from "@tsed/platform-response-filter";
|
|
7
|
-
export * from "@tsed/platform-cache";
|
|
8
7
|
export * from "@tsed/platform-middlewares";
|
|
9
8
|
export * from "@tsed/components-scan";
|
|
10
9
|
export * from "@tsed/platform-log-middleware";
|
|
10
|
+
export * from "@tsed/platform-router";
|
|
11
11
|
export { $log, Logger } from "@tsed/logger";
|
|
12
12
|
export { AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All } from "@tsed/schema";
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export * from "./exports";
|
|
5
5
|
export * from "./builder/PlatformBuilder";
|
|
6
|
-
export * from "./builder/PlatformControllerBuilder";
|
|
7
6
|
export * from "./config/interfaces/ConverterSettings";
|
|
8
|
-
export * from "./config/interfaces/EndpointDirectoriesSettings";
|
|
9
7
|
export * from "./config/interfaces/PlatformLoggerSettings";
|
|
10
8
|
export * from "./config/interfaces/PlatformMulterSettings";
|
|
11
9
|
export * from "./config/interfaces/PlatformStaticsSettings";
|
|
@@ -19,9 +17,7 @@ export * from "./decorators/params/next";
|
|
|
19
17
|
export * from "./decorators/params/request";
|
|
20
18
|
export * from "./decorators/params/response";
|
|
21
19
|
export * from "./domain/AnyToPromiseWithCtx";
|
|
22
|
-
export * from "./domain/ControllerProvider";
|
|
23
20
|
export * from "./domain/EndpointMetadata";
|
|
24
|
-
export * from "./domain/HandlerMetadata";
|
|
25
21
|
export * from "./domain/PlatformContext";
|
|
26
22
|
export * from "./domain/PlatformRouteDetails";
|
|
27
23
|
export * from "./interfaces/AfterInit";
|
|
@@ -41,7 +37,6 @@ export * from "./interfaces/ResponseErrorObject";
|
|
|
41
37
|
export * from "./interfaces/Route";
|
|
42
38
|
export * from "./middlewares/PlatformAcceptMimesMiddleware";
|
|
43
39
|
export * from "./middlewares/PlatformMulterMiddleware";
|
|
44
|
-
export * from "./middlewares/bindEndpointMiddleware";
|
|
45
40
|
export * from "./services/FakeAdapter";
|
|
46
41
|
export * from "./services/Platform";
|
|
47
42
|
export * from "./services/PlatformAdapter";
|
|
@@ -50,17 +45,14 @@ export * from "./services/PlatformHandler";
|
|
|
50
45
|
export * from "./services/PlatformMiddlewaresChain";
|
|
51
46
|
export * from "./services/PlatformRequest";
|
|
52
47
|
export * from "./services/PlatformResponse";
|
|
53
|
-
export * from "./services/PlatformRouter";
|
|
54
48
|
export * from "./services/PlatformTest";
|
|
55
49
|
export * from "./utils/createContext";
|
|
56
|
-
export * from "./utils/createHandlerMetadata";
|
|
57
50
|
export * from "./utils/createHttpServer";
|
|
58
51
|
export * from "./utils/createHttpsServer";
|
|
59
52
|
export * from "./utils/createInjector";
|
|
53
|
+
export * from "./utils/ensureContext";
|
|
60
54
|
export * from "./utils/getStaticsOptions";
|
|
61
|
-
export * from "./utils/importProviders";
|
|
62
55
|
export * from "./utils/listenServer";
|
|
63
56
|
export * from "./utils/mapReturnedResponse";
|
|
64
57
|
export * from "./utils/printRoutes";
|
|
65
58
|
export * from "./utils/setResponseHeaders";
|
|
66
|
-
export * from "./utils/useCtxHandler";
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { TokenProvider } from "@tsed/di";
|
|
2
|
-
import { ControllerProvider } from "../domain/ControllerProvider";
|
|
1
|
+
import { Provider, TokenProvider } from "@tsed/di";
|
|
3
2
|
export interface Route extends Record<string, any> {
|
|
4
3
|
route: string;
|
|
5
4
|
token: TokenProvider;
|
|
6
5
|
}
|
|
7
6
|
export interface RouteController {
|
|
8
7
|
route: string;
|
|
9
|
-
provider:
|
|
8
|
+
provider: Provider;
|
|
10
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { MulterError } from "multer";
|
|
2
1
|
import { BadRequest } from "@tsed/exceptions";
|
|
3
2
|
import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
4
3
|
import { Context } from "@tsed/platform-params";
|
|
4
|
+
import type { MulterError } from "multer";
|
|
5
5
|
import { PlatformMulterField, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
|
|
6
6
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
7
7
|
export interface MulterInputOptions {
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ProviderOpts } from "@tsed/di";
|
|
2
|
-
import {
|
|
2
|
+
import { PlatformContextHandler, PlatformLayer } from "@tsed/platform-router";
|
|
3
3
|
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings";
|
|
4
4
|
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings";
|
|
5
|
-
|
|
5
|
+
import { PlatformContext } from "../domain/PlatformContext";
|
|
6
|
+
import { PlatformAdapter } from "./PlatformAdapter";
|
|
7
|
+
export declare class FakeAdapter implements PlatformAdapter<any> {
|
|
6
8
|
providers: ProviderOpts[];
|
|
7
9
|
static createFakeRawDriver(): {
|
|
8
10
|
(): void;
|
|
@@ -21,10 +23,9 @@ export declare class FakeAdapter implements PlatformAdapter<any, any> {
|
|
|
21
23
|
callback(): any;
|
|
22
24
|
};
|
|
23
25
|
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
24
|
-
router(routerOptions: any): {
|
|
25
|
-
router: any;
|
|
26
|
-
callback(): any;
|
|
27
|
-
};
|
|
28
26
|
statics(endpoint: string, options: PlatformStaticsOptions): any;
|
|
29
27
|
bodyParser(type: string): any;
|
|
28
|
+
mapLayers(layers: PlatformLayer[]): void;
|
|
29
|
+
mapHandler(handler: PlatformContextHandler<PlatformContext>): PlatformContextHandler<PlatformContext<import("./PlatformRequest").PlatformRequest<any>, import("./PlatformResponse").PlatformResponse<any>>>;
|
|
30
|
+
useContext(): void;
|
|
30
31
|
}
|