@tsed/common 7.0.0-beta.12 → 7.0.0-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/jest.config.js +14 -0
- package/lib/cjs/builder/PlatformBuilder.js +65 -55
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/builder/PlatformControllerBuilder.js +1 -1
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +0 -70
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -3
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/cjs/domain/ControllerProvider.js +1 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -1
- package/lib/cjs/domain/HandlerMetadata.js +10 -5
- package/lib/cjs/domain/HandlerMetadata.js.map +1 -1
- package/lib/cjs/domain/PlatformContext.js +54 -31
- package/lib/cjs/domain/PlatformContext.js.map +1 -1
- package/lib/cjs/domain/PlatformRouteDetails.js +5 -1
- package/lib/cjs/domain/PlatformRouteDetails.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 +1 -3
- package/lib/cjs/services/FakeAdapter.js.map +1 -1
- package/lib/cjs/services/Platform.js +4 -2
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +12 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -1
- package/lib/cjs/services/PlatformApplication.js +2 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformHandler.js +7 -4
- package/lib/cjs/services/PlatformHandler.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +3 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +16 -11
- package/lib/cjs/services/PlatformRequest.js.map +1 -1
- package/lib/cjs/services/PlatformResponse.js +15 -11
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformRouter.js +7 -1
- package/lib/cjs/services/PlatformRouter.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +20 -8
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/createContext.js +28 -13
- 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 -6
- package/lib/cjs/utils/createInjector.js.map +1 -1
- package/lib/cjs/utils/getConfiguration.js +2 -12
- package/lib/cjs/utils/getConfiguration.js.map +1 -1
- package/lib/cjs/utils/setResponseHeaders.js +7 -13
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
- package/lib/esm/builder/PlatformBuilder.js +42 -55
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/builder/PlatformControllerBuilder.js +1 -1
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/esm/config/services/PlatformConfiguration.js +0 -70
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -3
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/esm/domain/ControllerProvider.js +1 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -1
- package/lib/esm/domain/HandlerMetadata.js +10 -5
- package/lib/esm/domain/HandlerMetadata.js.map +1 -1
- package/lib/esm/domain/PlatformContext.js +54 -31
- package/lib/esm/domain/PlatformContext.js.map +1 -1
- package/lib/esm/domain/PlatformRouteDetails.js +5 -1
- package/lib/esm/domain/PlatformRouteDetails.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 +1 -3
- package/lib/esm/services/FakeAdapter.js.map +1 -1
- package/lib/esm/services/Platform.js +4 -2
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +12 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -1
- package/lib/esm/services/PlatformApplication.js +2 -0
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformHandler.js +8 -5
- package/lib/esm/services/PlatformHandler.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +3 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/services/PlatformRequest.js +16 -11
- package/lib/esm/services/PlatformRequest.js.map +1 -1
- package/lib/esm/services/PlatformResponse.js +15 -11
- package/lib/esm/services/PlatformResponse.js.map +1 -1
- package/lib/esm/services/PlatformRouter.js +7 -1
- package/lib/esm/services/PlatformRouter.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +20 -8
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createContext.js +26 -12
- 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 -7
- package/lib/esm/utils/createInjector.js.map +1 -1
- package/lib/esm/utils/getConfiguration.js +4 -14
- package/lib/esm/utils/getConfiguration.js.map +1 -1
- package/lib/esm/utils/setResponseHeaders.js +7 -13
- package/lib/esm/utils/setResponseHeaders.js.map +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +4 -5
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
- package/lib/types/config/services/PlatformConfiguration.d.ts +1 -22
- package/lib/types/domain/PlatformContext.d.ts +20 -14
- package/lib/types/domain/PlatformRouteDetails.d.ts +1 -7
- package/lib/types/services/PlatformRequest.d.ts +11 -8
- package/lib/types/services/PlatformResponse.d.ts +8 -9
- package/lib/types/services/PlatformTest.d.ts +2 -2
- 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 +1 -1
- package/lib/types/utils/listenServer.d.ts +2 -0
- package/package.json +22 -21
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
- package/lib/cjs/middlewares/__mock__/FakeCtrl.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/__mock__/controllers/rest/TestCtrl.js +0 -12
- package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
- package/lib/cjs/utils/__mock__/module1/Module1.js +0 -19
- package/lib/cjs/utils/__mock__/module1/Module1.js.map +0 -1
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -17
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js +0 -17
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +0 -1
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +0 -15
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +0 -12
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +0 -1
- package/lib/cjs/utils/__mock__/module2/Module2.js +0 -18
- package/lib/cjs/utils/__mock__/module2/Module2.js.map +0 -1
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +0 -12
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.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/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/__mock__/controllers/rest/TestCtrl.js +0 -9
- package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +0 -1
- package/lib/esm/utils/__mock__/module1/Module1.js +0 -16
- package/lib/esm/utils/__mock__/module1/Module1.js.map +0 -1
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +0 -14
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +0 -1
- package/lib/esm/utils/__mock__/module1/services/M1Service.js +0 -14
- package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +0 -1
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +0 -12
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +0 -1
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js +0 -9
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +0 -1
- package/lib/esm/utils/__mock__/module2/Module2.js +0 -15
- package/lib/esm/utils/__mock__/module2/Module2.js.map +0 -1
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +0 -9
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +0 -1
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
- package/lib/types/utils/__mock__/Test1.d.ts +0 -3
- package/lib/types/utils/__mock__/Test2.d.ts +0 -3
- package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +0 -2
- package/lib/types/utils/__mock__/module1/Module1.d.ts +0 -2
- package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +0 -5
- package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +0 -5
- package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +0 -2
- package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +0 -2
- package/lib/types/utils/__mock__/module2/Module2.d.ts +0 -2
- package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC1C,MAAM,WAAW,GAAG,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAEhD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACjF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.get(\"httpPort\");\n const httpOptions = settings.get(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.set(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
|
|
@@ -4,8 +4,8 @@ import Https from "https";
|
|
|
4
4
|
import { listenServer } from "./listenServer.js";
|
|
5
5
|
export function createHttpsServer(injector, requestListener) {
|
|
6
6
|
const { settings } = injector;
|
|
7
|
-
const httpsPort = settings.
|
|
8
|
-
const httpsOptions = settings.
|
|
7
|
+
const httpsPort = settings.get("httpsPort");
|
|
8
|
+
const httpsOptions = settings.get("httpsOptions");
|
|
9
9
|
const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;
|
|
10
10
|
injector.addProvider(Https.Server, {
|
|
11
11
|
scope: ProviderScope.SINGLETON,
|
|
@@ -16,7 +16,7 @@ export function createHttpsServer(injector, requestListener) {
|
|
|
16
16
|
const hostInfo = getHostInfoFromPort("https", httpsPort);
|
|
17
17
|
return async () => {
|
|
18
18
|
const resolvedHostInfo = await listenServer(injector, server, hostInfo);
|
|
19
|
-
settings.
|
|
19
|
+
settings.set("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
|
|
20
20
|
return server;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAC,MAAM,UAAU,CAAC;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,QAAQ,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAElD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,mBAAmB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YAClF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.get(\"httpsPort\");\n const httpsOptions = settings.get(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.set(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { InjectorService, setLoggerLevel } from "@tsed/di";
|
|
2
|
-
import { $log } from "@tsed/logger";
|
|
3
1
|
import { toMap } from "@tsed/core";
|
|
2
|
+
import { InjectorService, setLoggerConfiguration } from "@tsed/di";
|
|
3
|
+
import { $log } from "@tsed/logger";
|
|
4
4
|
import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
|
|
5
|
+
import { Platform } from "../services/Platform.js";
|
|
6
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
7
|
+
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
5
8
|
import { PlatformHandler } from "../services/PlatformHandler.js";
|
|
9
|
+
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
6
10
|
import { PlatformResponse } from "../services/PlatformResponse.js";
|
|
7
11
|
import { PlatformRouter } from "../services/PlatformRouter.js";
|
|
8
|
-
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
9
|
-
import { Platform } from "../services/Platform.js";
|
|
10
|
-
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
11
|
-
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
12
12
|
$log.name = "TSED";
|
|
13
13
|
const DEFAULT_PROVIDERS = [
|
|
14
14
|
{ provide: PlatformHandler },
|
|
@@ -30,7 +30,7 @@ export function createInjector({ adapter, settings = {} }) {
|
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
32
|
injector.invoke(PlatformAdapter);
|
|
33
|
-
|
|
33
|
+
setLoggerConfiguration(injector);
|
|
34
34
|
const instance = injector.get(PlatformAdapter);
|
|
35
35
|
instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
|
|
36
36
|
toMap(instance.providers, "provide").forEach((provider, token) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,eAAe,EAAgB,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAE1D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,cAAc,EAAC;IACzB,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,eAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAEjC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IAEjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,eAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,KAAK,CAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,mBAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {toMap, Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, setLoggerConfiguration} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerConfiguration(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
|
|
@@ -1,15 +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
4
|
if (configuration.$$resolved) {
|
|
5
5
|
return configuration;
|
|
6
6
|
}
|
|
7
7
|
const store = module ? Store.from(module).get("configuration") || {} : {};
|
|
8
8
|
const env = configuration.env || store.env || process.env.NODE_ENV || Env.DEV;
|
|
9
|
-
|
|
9
|
+
return {
|
|
10
10
|
$$resolved: true,
|
|
11
|
-
exclude: ["**/*.spec.ts", "**/*.spec.js"],
|
|
12
|
-
componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
|
|
13
11
|
env,
|
|
14
12
|
httpPort: 8080,
|
|
15
13
|
httpsPort: false,
|
|
@@ -20,11 +18,7 @@ export function getConfiguration(configuration = {}, module = null) {
|
|
|
20
18
|
...store.scopes,
|
|
21
19
|
...configuration.scopes
|
|
22
20
|
},
|
|
23
|
-
mount: store.mount
|
|
24
|
-
? deepMerge(store.mount || {}, configuration.mount || {})
|
|
25
|
-
: {
|
|
26
|
-
"/rest": "${rootDir}/controllers/**/*.ts"
|
|
27
|
-
},
|
|
21
|
+
mount: mergeMount(store.mount, configuration.mount),
|
|
28
22
|
logger: {
|
|
29
23
|
debug: false,
|
|
30
24
|
level: env === Env.TEST ? "off" : "info",
|
|
@@ -34,9 +28,5 @@ export function getConfiguration(configuration = {}, module = null) {
|
|
|
34
28
|
jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
|
|
35
29
|
}
|
|
36
30
|
};
|
|
37
|
-
if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
|
|
38
|
-
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
39
|
-
}
|
|
40
|
-
return config;
|
|
41
31
|
}
|
|
42
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"]}
|
|
@@ -1,12 +1,3 @@
|
|
|
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
|
*/
|
|
@@ -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,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,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
3
|
import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
|
|
4
|
-
import { Platform } from "../services/Platform";
|
|
5
|
-
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
4
|
import type { IncomingMessage, ServerResponse } from "http";
|
|
5
|
+
import { Platform } from "../services/Platform";
|
|
7
6
|
import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
|
|
7
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
8
8
|
/**
|
|
9
9
|
* @platform
|
|
10
10
|
*/
|
|
@@ -41,7 +41,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
41
41
|
*
|
|
42
42
|
* @returns {PlatformConfiguration}
|
|
43
43
|
*/
|
|
44
|
-
get settings():
|
|
44
|
+
get settings(): import("@tsed/di").DIConfiguration;
|
|
45
45
|
get logger(): import("@tsed/di").DILogger;
|
|
46
46
|
get disableBootstrapLog(): any;
|
|
47
47
|
static create<App = TsED.Application, Router = TsED.Router>(module: Type<any>, settings: PlatformBuilderSettings<App, Router>): PlatformBuilder<App, Router>;
|
|
@@ -58,9 +58,8 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
58
58
|
/**
|
|
59
59
|
* Add classes to the components list
|
|
60
60
|
* @param classes
|
|
61
|
-
* @deprecated
|
|
62
61
|
*/
|
|
63
|
-
addComponents(classes:
|
|
62
|
+
addComponents(classes: Type | Type[]): this;
|
|
64
63
|
/**
|
|
65
64
|
* Add classes decorated by @@Controller@@ to components container.
|
|
66
65
|
*
|
|
@@ -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,18 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { getHostInfoFromPort } from "@tsed/core";
|
|
3
3
|
import { DIConfiguration, TokenProvider } from "@tsed/di";
|
|
4
4
|
import Https from "https";
|
|
5
5
|
import { ConverterSettings } from "../interfaces/ConverterSettings";
|
|
6
|
-
import { PlatformLoggerSettings } from "../interfaces/PlatformLoggerSettings";
|
|
7
6
|
/**
|
|
8
7
|
* `PlatformConfiguration` contains all information about your Server configuration.
|
|
9
8
|
*/
|
|
10
9
|
export declare class PlatformConfiguration extends DIConfiguration {
|
|
11
10
|
constructor();
|
|
12
|
-
get version(): string;
|
|
13
|
-
set version(v: string);
|
|
14
|
-
get rootDir(): string;
|
|
15
|
-
set rootDir(value: string);
|
|
16
11
|
get port(): string | number | false;
|
|
17
12
|
set port(value: string | number | false);
|
|
18
13
|
get httpsOptions(): Https.ServerOptions;
|
|
@@ -21,30 +16,14 @@ export declare class PlatformConfiguration extends DIConfiguration {
|
|
|
21
16
|
set httpPort(value: string | number | false);
|
|
22
17
|
get httpsPort(): string | number | false;
|
|
23
18
|
set httpsPort(value: string | number | false);
|
|
24
|
-
get env(): Env;
|
|
25
|
-
set env(value: Env);
|
|
26
19
|
get mount(): Record<string, TokenProvider[]>;
|
|
27
20
|
set mount(value: Record<string, TokenProvider[]>);
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated
|
|
30
|
-
*/
|
|
31
|
-
get componentsScan(): string[];
|
|
32
|
-
/**
|
|
33
|
-
* @deprecated
|
|
34
|
-
*/
|
|
35
|
-
set componentsScan(value: string[]);
|
|
36
21
|
get statics(): Record<string, (any | string)[]>;
|
|
37
22
|
set statics(value: Record<string, (any | string)[]>);
|
|
38
23
|
get acceptMimes(): string[];
|
|
39
24
|
set acceptMimes(value: string[]);
|
|
40
|
-
get debug(): boolean;
|
|
41
|
-
set debug(debug: boolean);
|
|
42
25
|
get converter(): Partial<ConverterSettings>;
|
|
43
26
|
set converter(options: Partial<ConverterSettings>);
|
|
44
|
-
get logger(): Partial<PlatformLoggerSettings>;
|
|
45
|
-
set logger(value: Partial<PlatformLoggerSettings>);
|
|
46
|
-
get exclude(): string[];
|
|
47
|
-
set exclude(exclude: string[]);
|
|
48
27
|
get additionalProperties(): boolean;
|
|
49
28
|
/**
|
|
50
29
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ContextMethods, DIContext, DIContextOptions } from "@tsed/di";
|
|
3
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
4
3
|
import { EndpointMetadata } from "@tsed/schema";
|
|
4
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
5
|
+
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
5
6
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
7
|
import { PlatformRequest } from "../services/PlatformRequest";
|
|
7
8
|
import { PlatformResponse } from "../services/PlatformResponse";
|
|
@@ -12,36 +13,40 @@ declare global {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
export interface PlatformContextOptions extends DIContextOptions {
|
|
15
|
-
event:
|
|
16
|
-
response?: ServerResponse;
|
|
17
|
-
request?: IncomingMessage;
|
|
18
|
-
};
|
|
16
|
+
event: IncomingEvent;
|
|
19
17
|
ignoreUrlPatterns?: any[];
|
|
20
18
|
endpoint?: EndpointMetadata;
|
|
21
19
|
}
|
|
22
|
-
export declare class PlatformContext extends DIContext implements ContextMethods {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
*/
|
|
26
|
-
endpoint: EndpointMetadata;
|
|
20
|
+
export declare class PlatformContext<PReq extends PlatformRequest = PlatformRequest, PRes extends PlatformResponse = PlatformResponse> extends DIContext implements ContextMethods {
|
|
21
|
+
#private;
|
|
22
|
+
event: IncomingEvent;
|
|
27
23
|
/**
|
|
28
24
|
* The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
29
25
|
*/
|
|
30
26
|
data: any;
|
|
27
|
+
/**
|
|
28
|
+
* The error caught by the current handler
|
|
29
|
+
*/
|
|
30
|
+
error?: unknown;
|
|
31
31
|
/**
|
|
32
32
|
* The current @@PlatformResponse@@.
|
|
33
33
|
*/
|
|
34
|
-
response:
|
|
34
|
+
readonly response: PRes;
|
|
35
35
|
/**
|
|
36
36
|
* The current @@PlatformRequest@@.
|
|
37
37
|
*/
|
|
38
|
-
request:
|
|
38
|
+
readonly request: PReq;
|
|
39
39
|
private ignoreUrlPatterns;
|
|
40
|
-
constructor(
|
|
40
|
+
constructor(options: PlatformContextOptions);
|
|
41
|
+
/**
|
|
42
|
+
* The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
|
|
43
|
+
*/
|
|
44
|
+
get endpoint(): EndpointMetadata;
|
|
45
|
+
set endpoint(endpoint: EndpointMetadata);
|
|
41
46
|
get url(): string;
|
|
42
47
|
get app(): PlatformApplication<TsED.Application, TsED.Router>;
|
|
43
48
|
destroy(): Promise<void>;
|
|
44
|
-
isDone():
|
|
49
|
+
isDone(): any;
|
|
45
50
|
/**
|
|
46
51
|
* Return the framework request instance (Express, Koa, etc...)
|
|
47
52
|
*/
|
|
@@ -62,4 +67,5 @@ export declare class PlatformContext extends DIContext implements ContextMethods
|
|
|
62
67
|
* Return the original application instance.
|
|
63
68
|
*/
|
|
64
69
|
getApp<T = any>(): T;
|
|
70
|
+
upgrade(event: IncomingEvent): void;
|
|
65
71
|
}
|
|
@@ -1,15 +1,9 @@
|
|
|
1
1
|
import { EndpointMetadata, JsonOperationRoute } from "@tsed/schema";
|
|
2
2
|
import { ControllerProvider } from "./ControllerProvider";
|
|
3
|
-
export interface PlatformRouterDetailsOptions {
|
|
4
|
-
provider: ControllerProvider;
|
|
5
|
-
endpoint: EndpointMetadata;
|
|
6
|
-
method: string;
|
|
7
|
-
url: string;
|
|
8
|
-
}
|
|
9
3
|
export declare class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {
|
|
10
4
|
readonly rawBody: boolean;
|
|
11
5
|
readonly provider: ControllerProvider;
|
|
12
|
-
constructor(options
|
|
6
|
+
constructor(options: Partial<PlatformRouteDetails>);
|
|
13
7
|
toJSON(): {
|
|
14
8
|
method: string;
|
|
15
9
|
name: string;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { IncomingHttpHeaders, IncomingMessage } from "http";
|
|
3
3
|
import type { PlatformContext } from "../domain/PlatformContext";
|
|
4
|
-
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
5
4
|
import type { PlatformResponse } from "./PlatformResponse";
|
|
6
5
|
declare global {
|
|
7
6
|
namespace TsED {
|
|
8
7
|
interface Request {
|
|
9
8
|
id: string;
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated
|
|
11
|
+
*/
|
|
10
12
|
$ctx: PlatformContext;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
@@ -15,16 +17,16 @@ declare global {
|
|
|
15
17
|
* Platform Request abstraction layer.
|
|
16
18
|
* @platform
|
|
17
19
|
*/
|
|
18
|
-
export declare class PlatformRequest<
|
|
20
|
+
export declare class PlatformRequest<Req extends {
|
|
19
21
|
[key: string]: any;
|
|
20
22
|
} = any> {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
readonly $ctx: PlatformContext;
|
|
24
|
+
constructor($ctx: PlatformContext);
|
|
23
25
|
/**
|
|
24
26
|
* The current @@PlatformResponse@@.
|
|
25
27
|
*/
|
|
26
|
-
response: PlatformResponse;
|
|
27
|
-
|
|
28
|
+
get response(): PlatformResponse;
|
|
29
|
+
get raw(): Req;
|
|
28
30
|
get secure(): boolean;
|
|
29
31
|
get host(): string;
|
|
30
32
|
get protocol(): string;
|
|
@@ -72,10 +74,11 @@ export declare class PlatformRequest<T extends {
|
|
|
72
74
|
[key: string]: any;
|
|
73
75
|
};
|
|
74
76
|
get files(): any;
|
|
77
|
+
get route(): any;
|
|
75
78
|
/**
|
|
76
79
|
* Return the original request framework instance
|
|
77
80
|
*/
|
|
78
|
-
get request():
|
|
81
|
+
get request(): Req;
|
|
79
82
|
/**
|
|
80
83
|
* Return the original request node.js instance
|
|
81
84
|
*/
|
|
@@ -104,7 +107,7 @@ export declare class PlatformRequest<T extends {
|
|
|
104
107
|
/**
|
|
105
108
|
* Return the Framework response object (express, koa, etc...)
|
|
106
109
|
*/
|
|
107
|
-
getRequest<
|
|
110
|
+
getRequest<R = Req>(): R;
|
|
108
111
|
/**
|
|
109
112
|
* Return the Node.js response object
|
|
110
113
|
*/
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { OutgoingHttpHeaders, ServerResponse } from "http";
|
|
3
|
-
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
4
3
|
import type { PlatformRequest } from "./PlatformRequest";
|
|
5
4
|
import type { PlatformContext } from "../domain/PlatformContext";
|
|
6
5
|
declare global {
|
|
@@ -14,15 +13,15 @@ export declare type HeaderValue = Array<boolean | number | string> | boolean | n
|
|
|
14
13
|
* Platform Response abstraction layer.
|
|
15
14
|
* @platform
|
|
16
15
|
*/
|
|
17
|
-
export declare class PlatformResponse<
|
|
18
|
-
|
|
16
|
+
export declare class PlatformResponse<Res extends Record<string, any> = any> {
|
|
17
|
+
readonly $ctx: PlatformContext;
|
|
18
|
+
data: any;
|
|
19
|
+
constructor($ctx: PlatformContext);
|
|
19
20
|
/**
|
|
20
21
|
* The current @@PlatformRequest@@.
|
|
21
22
|
*/
|
|
22
|
-
request: PlatformRequest;
|
|
23
|
-
|
|
24
|
-
raw: T;
|
|
25
|
-
constructor({ response }: IncomingEvent, $ctx: PlatformContext);
|
|
23
|
+
get request(): PlatformRequest;
|
|
24
|
+
get raw(): Res;
|
|
26
25
|
/**
|
|
27
26
|
* Get the current statusCode
|
|
28
27
|
*/
|
|
@@ -36,7 +35,7 @@ export declare class PlatformResponse<T extends Record<string, any> = any> {
|
|
|
36
35
|
/**
|
|
37
36
|
* Return the original response framework instance
|
|
38
37
|
*/
|
|
39
|
-
get response():
|
|
38
|
+
get response(): Res;
|
|
40
39
|
/**
|
|
41
40
|
* Return the original response node.js instance
|
|
42
41
|
*/
|
|
@@ -56,7 +55,7 @@ export declare class PlatformResponse<T extends Record<string, any> = any> {
|
|
|
56
55
|
/**
|
|
57
56
|
* Return the Framework response object (express, koa, etc...)
|
|
58
57
|
*/
|
|
59
|
-
getResponse<
|
|
58
|
+
getResponse<R = Res>(): R;
|
|
60
59
|
/**
|
|
61
60
|
* Return the Node.js response object
|
|
62
61
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DITest, DITestOptions, InjectorService } from "@tsed/di";
|
|
2
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { DITest, DITestOptions, InjectorService } from "@tsed/di";
|
|
3
3
|
import { PlatformContext, PlatformContextOptions } from "../domain/PlatformContext";
|
|
4
4
|
import { PlatformAdapter, PlatformBuilderSettings } from "./PlatformAdapter";
|
|
5
5
|
/**
|
|
@@ -54,5 +54,5 @@ export declare class PlatformTest extends DITest {
|
|
|
54
54
|
static callback(): any;
|
|
55
55
|
static createRequest(options?: any): any;
|
|
56
56
|
static createResponse(options?: any): any;
|
|
57
|
-
static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext
|
|
57
|
+
static createRequestContext(options?: Partial<PlatformContextOptions & any>): PlatformContext<import("./PlatformRequest").PlatformRequest<any>, import("./PlatformResponse").PlatformResponse<any>>;
|
|
58
58
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { InjectorService } from "@tsed/di";
|
|
2
2
|
import { PlatformContext } from "../domain/PlatformContext";
|
|
3
|
+
import { PlatformRequest } from "../services/PlatformRequest";
|
|
4
|
+
import { PlatformResponse } from "../services/PlatformResponse";
|
|
3
5
|
import { IncomingEvent } from "../interfaces/IncomingEvent";
|
|
6
|
+
export declare function ignoreLog(ignoreUrlPatterns: any[] | undefined): ((ignore: boolean, data: any, url: string) => any) | undefined;
|
|
4
7
|
/**
|
|
5
8
|
* Create the TsED context to wrap request, response, injector, etc...
|
|
6
9
|
* @param injector
|
|
7
10
|
* @ignore
|
|
8
11
|
*/
|
|
9
|
-
export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext
|
|
12
|
+
export declare function createContext(injector: InjectorService): (event: IncomingEvent) => Promise<PlatformContext<PlatformRequest<any>, PlatformResponse<any>>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { InjectorService } from "@tsed/di";
|
|
2
1
|
import { Type } from "@tsed/core";
|
|
2
|
+
import { InjectorService } from "@tsed/di";
|
|
3
3
|
import { PlatformAdapter } from "../services/PlatformAdapter";
|
|
4
4
|
interface CreateInjectorOptions {
|
|
5
5
|
adapter?: Type<PlatformAdapter<any, any>>;
|