@tsed/common 7.0.0-beta.2 → 7.0.0-beta.20
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 +94 -65
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +2 -66
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/cjs/decorators/multer/multipartFile.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/EndpointMetadata.js +2 -66
- package/lib/cjs/domain/EndpointMetadata.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 +32 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +58 -30
- 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 +10 -9
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +27 -13
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FakeAdapter.js +49 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +33 -68
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +24 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +26 -14
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformHandler.js +115 -172
- package/lib/cjs/services/PlatformHandler.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +46 -19
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +17 -13
- package/lib/cjs/services/PlatformRequest.js.map +1 -1
- package/lib/cjs/services/PlatformResponse.js +20 -23
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +31 -10
- 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 +6 -11
- package/lib/cjs/utils/createHttpServer.js.map +1 -1
- package/lib/cjs/utils/createHttpsServer.js +6 -11
- package/lib/cjs/utils/createHttpsServer.js.map +1 -1
- package/lib/cjs/utils/createInjector.js +16 -10
- 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 +74 -68
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformMulterSettings.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/multer/multerFileSize.js +1 -1
- package/lib/esm/decorators/multer/multerOptions.js +1 -1
- package/lib/esm/decorators/multer/multipartFile.js +1 -1
- package/lib/esm/decorators/multer/multipartFile.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/EndpointMetadata.js +1 -66
- package/lib/esm/domain/EndpointMetadata.js.map +1 -1
- package/lib/esm/domain/PlatformContext.js +49 -41
- 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 +14 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +58 -27
- 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 +18 -5
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FakeAdapter.js +45 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +34 -69
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +20 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +27 -15
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformHandler.js +116 -173
- package/lib/esm/services/PlatformHandler.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +49 -22
- 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 +34 -14
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createContext.js +33 -23
- package/lib/esm/utils/createContext.js.map +1 -1
- package/lib/esm/utils/createHttpServer.js +6 -11
- package/lib/esm/utils/createHttpServer.js.map +1 -1
- package/lib/esm/utils/createHttpsServer.js +6 -11
- package/lib/esm/utils/createHttpsServer.js.map +1 -1
- package/lib/esm/utils/createInjector.js +20 -14
- 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 +19 -17
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
- package/lib/types/config/services/PlatformConfiguration.d.ts +6 -21
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
- package/lib/types/domain/EndpointMetadata.d.ts +1 -50
- package/lib/types/domain/PlatformContext.d.ts +32 -18
- package/lib/types/domain/PlatformRouteDetails.d.ts +4 -20
- package/lib/types/exports.d.ts +13 -0
- package/lib/types/index.d.ts +56 -18
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -2
- package/lib/types/interfaces/Route.d.ts +2 -3
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
- package/lib/types/services/FakeAdapter.d.ts +31 -0
- package/lib/types/services/Platform.d.ts +9 -21
- package/lib/types/services/PlatformAdapter.d.ts +58 -0
- package/lib/types/services/PlatformApplication.d.ts +15 -7
- package/lib/types/services/PlatformHandler.d.ts +21 -59
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -3
- package/lib/types/services/PlatformRequest.d.ts +8 -10
- package/lib/types/services/PlatformResponse.d.ts +15 -19
- package/lib/types/services/PlatformTest.d.ts +5 -4
- package/lib/types/utils/createContext.d.ts +4 -1
- package/lib/types/utils/createHttpServer.d.ts +1 -1
- package/lib/types/utils/createHttpsServer.d.ts +3 -1
- package/lib/types/utils/createInjector.d.ts +5 -3
- package/lib/types/utils/ensureContext.d.ts +2 -0
- package/lib/types/utils/listenServer.d.ts +2 -0
- package/package.json +43 -26
- package/readme.md +52 -58
- package/tsconfig.compile.esm.json +2 -12
- package/lib/cjs/builder/PlatformControllerBuilder.js +0 -85
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/cjs/config/index.js +0 -7
- package/lib/cjs/config/index.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/config/interfaces/index.js +0 -8
- package/lib/cjs/config/interfaces/index.js.map +0 -1
- package/lib/cjs/decorators/httpServer.js +0 -32
- package/lib/cjs/decorators/httpServer.js.map +0 -1
- package/lib/cjs/decorators/httpsServer.js +0 -32
- package/lib/cjs/decorators/httpsServer.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -21
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/decorators/method/acceptMime.js +0 -28
- package/lib/cjs/decorators/method/acceptMime.js.map +0 -1
- package/lib/cjs/decorators/method/endpointFn.js +0 -15
- package/lib/cjs/decorators/method/endpointFn.js.map +0 -1
- package/lib/cjs/decorators/method/location.js +0 -6
- package/lib/cjs/decorators/method/location.js.map +0 -1
- package/lib/cjs/decorators/method/redirect.js +0 -6
- package/lib/cjs/decorators/method/redirect.js.map +0 -1
- package/lib/cjs/decorators/method/route.js +0 -13
- package/lib/cjs/decorators/method/route.js.map +0 -1
- package/lib/cjs/decorators/method/view.js +0 -34
- package/lib/cjs/decorators/method/view.js.map +0 -1
- package/lib/cjs/decorators/multer/index.js +0 -7
- package/lib/cjs/decorators/multer/index.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/domain/index.js +0 -10
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/cjs/interfaces/PathType.js +0 -3
- package/lib/cjs/interfaces/PathType.js.map +0 -1
- package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
- package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -21
- package/lib/cjs/interfaces/index.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/middlewares/index.js +0 -7
- package/lib/cjs/middlewares/index.js.map +0 -1
- package/lib/cjs/services/FakeRawDriver.js +0 -26
- package/lib/cjs/services/FakeRawDriver.js.map +0 -1
- package/lib/cjs/services/PlatformRouter.js +0 -126
- package/lib/cjs/services/PlatformRouter.js.map +0 -1
- package/lib/cjs/services/index.js +0 -12
- package/lib/cjs/services/index.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/index.js +0 -11
- package/lib/cjs/utils/index.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 -79
- package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/esm/config/index.js +0 -4
- package/lib/esm/config/index.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/config/interfaces/index.js +0 -5
- package/lib/esm/config/interfaces/index.js.map +0 -1
- package/lib/esm/decorators/httpServer.js +0 -28
- package/lib/esm/decorators/httpServer.js.map +0 -1
- package/lib/esm/decorators/httpsServer.js +0 -28
- package/lib/esm/decorators/httpsServer.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -18
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/decorators/method/acceptMime.js +0 -24
- package/lib/esm/decorators/method/acceptMime.js.map +0 -1
- package/lib/esm/decorators/method/endpointFn.js +0 -11
- package/lib/esm/decorators/method/endpointFn.js.map +0 -1
- package/lib/esm/decorators/method/location.js +0 -2
- package/lib/esm/decorators/method/location.js.map +0 -1
- package/lib/esm/decorators/method/redirect.js +0 -2
- package/lib/esm/decorators/method/redirect.js.map +0 -1
- package/lib/esm/decorators/method/route.js +0 -2
- package/lib/esm/decorators/method/route.js.map +0 -1
- package/lib/esm/decorators/method/view.js +0 -30
- package/lib/esm/decorators/method/view.js.map +0 -1
- package/lib/esm/decorators/multer/index.js +0 -4
- package/lib/esm/decorators/multer/index.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/domain/index.js +0 -7
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/esm/interfaces/PathType.js +0 -2
- package/lib/esm/interfaces/PathType.js.map +0 -1
- package/lib/esm/interfaces/PlatformAdapter.js +0 -2
- package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -18
- package/lib/esm/interfaces/index.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/middlewares/index.js +0 -4
- package/lib/esm/middlewares/index.js.map +0 -1
- package/lib/esm/services/FakeRawDriver.js +0 -22
- package/lib/esm/services/FakeRawDriver.js.map +0 -1
- package/lib/esm/services/PlatformRouter.js +0 -123
- package/lib/esm/services/PlatformRouter.js.map +0 -1
- package/lib/esm/services/index.js +0 -9
- package/lib/esm/services/index.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/index.js +0 -8
- package/lib/esm/utils/index.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 -17
- package/lib/types/config/index.d.ts +0 -3
- package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
- package/lib/types/config/interfaces/index.d.ts +0 -97
- package/lib/types/decorators/httpServer.d.ts +0 -28
- package/lib/types/decorators/httpsServer.d.ts +0 -28
- package/lib/types/decorators/index.d.ts +0 -14
- package/lib/types/decorators/method/acceptMime.d.ts +0 -19
- package/lib/types/decorators/method/endpointFn.d.ts +0 -9
- package/lib/types/decorators/method/location.d.ts +0 -1
- package/lib/types/decorators/method/redirect.d.ts +0 -1
- package/lib/types/decorators/method/route.d.ts +0 -1
- package/lib/types/decorators/method/view.d.ts +0 -25
- package/lib/types/decorators/multer/index.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/domain/index.d.ts +0 -6
- package/lib/types/interfaces/PathType.d.ts +0 -1
- package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
- package/lib/types/interfaces/index.d.ts +0 -17
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -5
- package/lib/types/middlewares/index.d.ts +0 -3
- package/lib/types/services/FakeRawDriver.d.ts +0 -15
- package/lib/types/services/PlatformRouter.d.ts +0 -48
- package/lib/types/services/index.d.ts +0 -8
- package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
- package/lib/types/utils/index.d.ts +0 -7
- package/lib/types/utils/useCtxHandler.d.ts +0 -13
|
@@ -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,24 +1,26 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Type } from "@tsed/core";
|
|
3
|
-
import { InjectorService,
|
|
3
|
+
import { InjectorService, ProviderOpts, TokenProvider } from "@tsed/di";
|
|
4
|
+
import { PlatformLayer } from "@tsed/platform-router";
|
|
5
|
+
import type { IncomingMessage, ServerResponse } from "http";
|
|
4
6
|
import { Platform } from "../services/Platform";
|
|
7
|
+
import { PlatformAdapter, PlatformBuilderSettings } from "../services/PlatformAdapter";
|
|
5
8
|
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
|
-
import { IncomingMessage, ServerResponse } from "http";
|
|
7
|
-
import { PlatformAdapter, PlatformBuilderSettings } from "../interfaces/PlatformAdapter";
|
|
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
|
|
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;
|
|
23
|
+
get adapter(): PlatformAdapter<App>;
|
|
22
24
|
/**
|
|
23
25
|
* Return the settings configured by the decorator @@Configuration@@.
|
|
24
26
|
*
|
|
@@ -40,17 +42,17 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
40
42
|
*
|
|
41
43
|
* @returns {PlatformConfiguration}
|
|
42
44
|
*/
|
|
43
|
-
get settings():
|
|
45
|
+
get settings(): import("@tsed/di").DIConfiguration;
|
|
44
46
|
get logger(): import("@tsed/di").DILogger;
|
|
45
|
-
get disableBootstrapLog():
|
|
46
|
-
static create<App = TsED.Application
|
|
47
|
-
static build<App = TsED.Application
|
|
47
|
+
get disableBootstrapLog(): any;
|
|
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>;
|
|
48
50
|
/**
|
|
49
51
|
* Bootstrap a server application
|
|
50
52
|
* @param module
|
|
51
53
|
* @param settings
|
|
52
54
|
*/
|
|
53
|
-
static bootstrap<App = TsED.Application
|
|
55
|
+
static bootstrap<App = TsED.Application>(module: Type<any>, settings: PlatformBuilderSettings<App>): Promise<PlatformBuilder<App>>;
|
|
54
56
|
callback(): (req: IncomingMessage, res: ServerResponse) => void;
|
|
55
57
|
callback(req: IncomingMessage, res: ServerResponse): void;
|
|
56
58
|
log(...data: any[]): any;
|
|
@@ -58,7 +60,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
58
60
|
* Add classes to the components list
|
|
59
61
|
* @param classes
|
|
60
62
|
*/
|
|
61
|
-
addComponents(classes:
|
|
63
|
+
addComponents(classes: Type | Type[]): this;
|
|
62
64
|
/**
|
|
63
65
|
* Add classes decorated by @@Controller@@ to components container.
|
|
64
66
|
*
|
|
@@ -79,7 +81,7 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
79
81
|
* @param {string} endpoint
|
|
80
82
|
* @param {any[]} controllers
|
|
81
83
|
*/
|
|
82
|
-
addControllers(endpoint: string, controllers:
|
|
84
|
+
addControllers(endpoint: string, controllers: TokenProvider | TokenProvider[]): void;
|
|
83
85
|
runLifecycle(): Promise<this>;
|
|
84
86
|
loadInjector(): Promise<void>;
|
|
85
87
|
listen(network?: boolean): Promise<void>;
|
|
@@ -87,11 +89,11 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
87
89
|
ready(): Promise<void>;
|
|
88
90
|
callHook(hook: string, ...args: any[]): Promise<void>;
|
|
89
91
|
loadStatics(hook: string): Promise<void>;
|
|
90
|
-
useProvider(token: Type<any>, settings?: Partial<
|
|
92
|
+
useProvider(token: Type<any>, settings?: Partial<ProviderOpts>): this;
|
|
91
93
|
bootstrap(): Promise<this>;
|
|
92
94
|
protected loadRoutes(): Promise<void>;
|
|
95
|
+
protected mapRouters(): Promise<void>;
|
|
93
96
|
protected diff(): string;
|
|
94
|
-
protected importProviders(): Promise<void>;
|
|
95
97
|
/**
|
|
96
98
|
* Load middlewares from configuration for the given hook
|
|
97
99
|
* @param hook
|
|
@@ -100,5 +102,5 @@ export declare class PlatformBuilder<App = TsED.Application, Router = TsED.Route
|
|
|
100
102
|
protected loadMiddlewaresFor(hook: string): void;
|
|
101
103
|
protected createHttpServers(): void;
|
|
102
104
|
protected listenServers(): Promise<void>;
|
|
103
|
-
protected logRoutes(): Promise<void>;
|
|
105
|
+
protected logRoutes(layers: PlatformLayer[]): Promise<void>;
|
|
104
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,135 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
import { FileFilterCallback } from "multer";
|
|
3
|
-
import { Readable } from "stream";
|
|
1
|
+
import type multer from "multer";
|
|
4
2
|
declare global {
|
|
5
3
|
namespace TsED {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/** Value of the `Content-Type` header for this file. */
|
|
12
|
-
mimetype: string;
|
|
13
|
-
/** Size of the file in bytes. */
|
|
14
|
-
size: number;
|
|
15
|
-
/**
|
|
16
|
-
* A readable stream of this file. Only available to the `_handleFile`
|
|
17
|
-
* callback for custom `StorageEngine`s.
|
|
18
|
-
*/
|
|
19
|
-
stream: Readable;
|
|
20
|
-
/** `DiskStorage` only: Directory to which this file has been uploaded. */
|
|
21
|
-
destination: string;
|
|
22
|
-
/** `DiskStorage` only: Name of this file within `destination`. */
|
|
23
|
-
filename: string;
|
|
24
|
-
/** `DiskStorage` only: Full path to the uploaded file. */
|
|
25
|
-
path: string;
|
|
26
|
-
/** `MemoryStorage` only: A Buffer containing the entire file. */
|
|
27
|
-
buffer: Buffer;
|
|
28
|
-
}
|
|
29
|
-
interface MulterStorageEngine {
|
|
30
|
-
}
|
|
31
|
-
interface MulterOptions {
|
|
32
|
-
/**
|
|
33
|
-
* A `StorageEngine` responsible for processing files uploaded via Multer.
|
|
34
|
-
* Takes precedence over `dest`.
|
|
35
|
-
*/
|
|
36
|
-
storage?: MulterStorageEngine;
|
|
37
|
-
/**
|
|
38
|
-
* The destination directory for uploaded files. If `storage` is not set
|
|
39
|
-
* and `dest` is, Multer will create a `DiskStorage` instance configured
|
|
40
|
-
* to store files at `dest` with random filenames.
|
|
41
|
-
*
|
|
42
|
-
* Ignored if `storage` is set.
|
|
43
|
-
*/
|
|
44
|
-
dest?: string;
|
|
45
|
-
/**
|
|
46
|
-
* An object specifying various limits on incoming data. This object is
|
|
47
|
-
* passed to Busboy directly, and the details of properties can be found
|
|
48
|
-
* at https://github.com/mscdex/busboy#busboy-methods.
|
|
49
|
-
*/
|
|
50
|
-
limits?: {
|
|
51
|
-
/** Maximum size of each form field name in bytes. (Default: 100) */
|
|
52
|
-
fieldNameSize?: number;
|
|
53
|
-
/** Maximum size of each form field value in bytes. (Default: 1048576) */
|
|
54
|
-
fieldSize?: number;
|
|
55
|
-
/** Maximum number of non-file form fields. (Default: Infinity) */
|
|
56
|
-
fields?: number;
|
|
57
|
-
/** Maximum size of each file in bytes. (Default: Infinity) */
|
|
58
|
-
fileSize?: number;
|
|
59
|
-
/** Maximum number of file fields. (Default: Infinity) */
|
|
60
|
-
files?: number;
|
|
61
|
-
/** Maximum number of parts (non-file fields + files). (Default: Infinity) */
|
|
62
|
-
parts?: number;
|
|
63
|
-
/** Maximum number of headers. (Default: 2000) */
|
|
64
|
-
headerPairs?: number;
|
|
65
|
-
};
|
|
66
|
-
/** Preserve the full path of the original filename rather than the basename. (Default: false) */
|
|
67
|
-
preservePath?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Optional function to control which files are uploaded. This is called
|
|
70
|
-
* for every file that is processed.
|
|
71
|
-
*
|
|
72
|
-
* @param req The Express `Request` object.
|
|
73
|
-
* @param file Object containing information about the processed file.
|
|
74
|
-
* @param callback a function to control which files should be uploaded and which should be skipped.
|
|
75
|
-
*/
|
|
76
|
-
fileFilter?(req: Request, file: MulterFile, callback: FileFilterCallback): void;
|
|
77
|
-
}
|
|
78
|
-
interface MulterField {
|
|
79
|
-
name: string;
|
|
80
|
-
maxCount?: number;
|
|
81
|
-
}
|
|
82
|
-
type MulterHandler = (req: any, res: any) => Promise<any>;
|
|
83
|
-
interface Multer {
|
|
84
|
-
/**
|
|
85
|
-
* Returns middleware that processes a single file associated with the
|
|
86
|
-
* given form field.
|
|
87
|
-
*
|
|
88
|
-
* The `Request` object will be populated with a `file` object containing
|
|
89
|
-
* information about the processed file.
|
|
90
|
-
*
|
|
91
|
-
* @param fieldName Name of the multipart form field to process.
|
|
92
|
-
*/
|
|
93
|
-
single(fieldName: string): MulterHandler;
|
|
94
|
-
/**
|
|
95
|
-
* Returns middleware that processes multiple files sharing the same field
|
|
96
|
-
* name.
|
|
97
|
-
*
|
|
98
|
-
* The `Request` object will be populated with a `files` array containing
|
|
99
|
-
* an information object for each processed file.
|
|
100
|
-
*
|
|
101
|
-
* @param fieldName Shared name of the multipart form fields to process.
|
|
102
|
-
* @param maxCount Optional. Maximum number of files to process. (default: Infinity)
|
|
103
|
-
* @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName`
|
|
104
|
-
*/
|
|
105
|
-
array(fieldName: string, maxCount?: number): MulterHandler;
|
|
106
|
-
/**
|
|
107
|
-
* Returns middleware that processes multiple files associated with the
|
|
108
|
-
* given form fields.
|
|
109
|
-
*
|
|
110
|
-
* The `Request` object will be populated with a `files` object which
|
|
111
|
-
* maps each field name to an array of the associated file information
|
|
112
|
-
* objects.
|
|
113
|
-
*
|
|
114
|
-
* @param fields Array of `Field` objects describing multipart form fields to process.
|
|
115
|
-
* @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if more than `maxCount` files are associated with `fieldName` for any field.
|
|
116
|
-
*/
|
|
117
|
-
fields(fields: MulterField[]): MulterHandler;
|
|
118
|
-
/**
|
|
119
|
-
* Returns middleware that processes all files contained in the multipart
|
|
120
|
-
* request.
|
|
121
|
-
*
|
|
122
|
-
* The `Request` object will be populated with a `files` array containing
|
|
123
|
-
* an information object for each processed file.
|
|
124
|
-
*/
|
|
125
|
-
any(): MulterHandler;
|
|
126
|
-
/**
|
|
127
|
-
* Returns middleware that accepts only non-file multipart form fields.
|
|
128
|
-
*
|
|
129
|
-
* @throws `MulterError('LIMIT_UNEXPECTED_FILE')` if any file is encountered.
|
|
130
|
-
*/
|
|
131
|
-
none(): MulterHandler;
|
|
132
|
-
}
|
|
4
|
+
type MulterFile = Express.Multer.File;
|
|
5
|
+
type MulterStorageEngine = multer.StorageEngine;
|
|
6
|
+
type MulterOptions = multer.Options;
|
|
7
|
+
type MulterField = multer.Field;
|
|
8
|
+
type Multer = multer.Multer;
|
|
133
9
|
}
|
|
134
10
|
}
|
|
135
11
|
export declare type PlatformMulter = TsED.Multer;
|
|
@@ -1,18 +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
|
-
import { EndpointDirectoriesSettings, PlatformLoggerSettings } from "../interfaces";
|
|
6
5
|
import { ConverterSettings } from "../interfaces/ConverterSettings";
|
|
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,24 +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
|
|
25
|
-
set
|
|
26
|
-
get
|
|
27
|
-
set
|
|
28
|
-
get componentsScan(): string[];
|
|
29
|
-
set componentsScan(value: string[]);
|
|
30
|
-
get statics(): EndpointDirectoriesSettings;
|
|
31
|
-
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)[]>);
|
|
32
23
|
get acceptMimes(): string[];
|
|
33
24
|
set acceptMimes(value: string[]);
|
|
34
|
-
get debug(): boolean;
|
|
35
|
-
set debug(debug: boolean);
|
|
36
25
|
get converter(): Partial<ConverterSettings>;
|
|
37
26
|
set converter(options: Partial<ConverterSettings>);
|
|
38
|
-
get logger(): Partial<PlatformLoggerSettings>;
|
|
39
|
-
set logger(value: Partial<PlatformLoggerSettings>);
|
|
40
|
-
get exclude(): string[];
|
|
41
|
-
set exclude(exclude: string[]);
|
|
42
27
|
get additionalProperties(): boolean;
|
|
43
28
|
/**
|
|
44
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,50 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { ParamMetadata } from "@tsed/platform-params";
|
|
3
|
-
import { JsonMethodStore } from "@tsed/schema";
|
|
4
|
-
export interface EndpointViewOptions {
|
|
5
|
-
path: string;
|
|
6
|
-
options: any;
|
|
7
|
-
}
|
|
8
|
-
export interface EndpointRedirectOptions {
|
|
9
|
-
status: number | undefined;
|
|
10
|
-
url: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* EndpointMetadata contains metadata about a controller and his method.
|
|
14
|
-
* Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.
|
|
15
|
-
* EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
|
|
16
|
-
*
|
|
17
|
-
* Example :
|
|
18
|
-
*
|
|
19
|
-
* @Controller("/my-path")
|
|
20
|
-
* provide MyClass {
|
|
21
|
-
*
|
|
22
|
-
* @Get("/")
|
|
23
|
-
* @Authenticated()
|
|
24
|
-
* public myMethod(){}
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
*/
|
|
28
|
-
export declare class EndpointMetadata extends JsonMethodStore {
|
|
29
|
-
get targetName(): string;
|
|
30
|
-
get params(): ParamMetadata[];
|
|
31
|
-
get view(): EndpointViewOptions;
|
|
32
|
-
set view(view: EndpointViewOptions);
|
|
33
|
-
get acceptMimes(): string[];
|
|
34
|
-
set acceptMimes(mimes: string[]);
|
|
35
|
-
/**
|
|
36
|
-
* Get an endpoint.
|
|
37
|
-
* @param target
|
|
38
|
-
* @param propertyKey
|
|
39
|
-
* @param descriptor
|
|
40
|
-
*/
|
|
41
|
-
static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata;
|
|
42
|
-
addOperationPath(method: string, path: string | RegExp, options?: any): import("@tsed/schema").JsonOperation;
|
|
43
|
-
/**
|
|
44
|
-
* Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
|
|
45
|
-
*
|
|
46
|
-
* @param key
|
|
47
|
-
* @returns {any}
|
|
48
|
-
*/
|
|
49
|
-
get<T = any>(key: any): T;
|
|
50
|
-
}
|
|
1
|
+
export { EndpointMetadata } from "@tsed/schema";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { DIContext, DIContextOptions } from "@tsed/di";
|
|
3
|
+
import { PlatformHandlerMetadata } from "@tsed/platform-router";
|
|
4
|
+
import { EndpointMetadata } from "@tsed/schema";
|
|
3
5
|
import { IncomingMessage, ServerResponse } from "http";
|
|
4
|
-
import {
|
|
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
|
*/
|