@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
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uCAAuC,CAAC;AACtD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"
|
|
1
|
+
{"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"@tsed/di\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"@tsed/di\";\
|
|
1
|
+
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {Provider, TokenProvider} from \"@tsed/di\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: Provider;\n}\n"]}
|
|
@@ -9,9 +9,10 @@ import { Context } from "@tsed/platform-params";
|
|
|
9
9
|
* @platform
|
|
10
10
|
*/
|
|
11
11
|
let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
|
|
12
|
+
acceptMimes;
|
|
12
13
|
use(ctx) {
|
|
13
14
|
const { endpoint, request } = ctx;
|
|
14
|
-
const mimes = uniq((
|
|
15
|
+
const mimes = uniq((endpoint?.get("acceptMimes") || []).concat(this.acceptMimes));
|
|
15
16
|
if (mimes.length && !request.accepts(mimes)) {
|
|
16
17
|
throw new NotAcceptable(mimes.join(", "));
|
|
17
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;
|
|
1
|
+
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAExC,WAAW,CAAW;IAEf,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF,CAAA;AAVC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;kEACN;AAEtB;IAAY,WAAA,OAAO,EAAE,CAAA;;;;wDAOpB;AAXU,6BAA6B;IADzC,UAAU,EAAE;GACA,6BAA6B,CAYzC;SAZY,6BAA6B","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport {Constant} from \"@tsed/di\";\nimport {NotAcceptable} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\n\n/**\n * @middleware\n * @platform\n */\n@Middleware()\nexport class PlatformAcceptMimesMiddleware implements MiddlewareMethods {\n @Constant(\"acceptMimes\", [])\n acceptMimes: string[];\n\n public use(@Context() ctx: Context): void {\n const {endpoint, request} = ctx;\n const mimes = uniq((endpoint?.get(\"acceptMimes\") || []).concat(this.acceptMimes));\n\n if (mimes.length && !request.accepts(mimes)) {\n throw new NotAcceptable(mimes.join(\", \"));\n }\n }\n}\n"]}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
var PlatformMulterMiddleware_1;
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Inject, Value } from "@tsed/di";
|
|
4
|
+
import { BadRequest } from "@tsed/exceptions";
|
|
5
5
|
import { Middleware } from "@tsed/platform-middlewares";
|
|
6
6
|
import { Context } from "@tsed/platform-params";
|
|
7
|
-
import { PlatformApplication } from "../services/PlatformApplication";
|
|
7
|
+
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
8
|
+
export class MulterException extends BadRequest {
|
|
9
|
+
constructor(er) {
|
|
10
|
+
super(er.message);
|
|
11
|
+
this.origin = er;
|
|
12
|
+
this.name = er.code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
/**
|
|
9
16
|
* @middleware
|
|
10
17
|
*/
|
|
11
18
|
let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulterMiddleware {
|
|
19
|
+
settings;
|
|
20
|
+
app;
|
|
12
21
|
async use(ctx) {
|
|
13
22
|
try {
|
|
14
23
|
const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware_1);
|
|
@@ -24,7 +33,10 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
|
|
|
24
33
|
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
25
34
|
}
|
|
26
35
|
catch (er) {
|
|
27
|
-
|
|
36
|
+
if (er.code) {
|
|
37
|
+
throw new MulterException(er);
|
|
38
|
+
}
|
|
39
|
+
throw er;
|
|
28
40
|
}
|
|
29
41
|
}
|
|
30
42
|
getFields(conf) {
|
|
@@ -32,7 +44,8 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
|
|
|
32
44
|
}
|
|
33
45
|
};
|
|
34
46
|
__decorate([
|
|
35
|
-
|
|
47
|
+
Value("multer", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840
|
|
48
|
+
,
|
|
36
49
|
__metadata("design:type", Object)
|
|
37
50
|
], PlatformMulterMiddleware.prototype, "settings", void 0);
|
|
38
51
|
__decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAG9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAMpE,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAyB;IAGjC,GAAG,CAAsB;IAEnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,MAAM,EAAE;8BACM,mBAAmB;qDAAC;AAEnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAmCpC;SAnCY,wBAAwB","sourcesContent":["import {Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport type {MulterError} from \"multer\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export class FakeAdapter {
|
|
2
|
+
providers = [];
|
|
3
|
+
static createFakeRawDriver() {
|
|
4
|
+
// istanbul ignore next
|
|
5
|
+
function FakeRawDriver() { }
|
|
6
|
+
// istanbul ignore next
|
|
7
|
+
function use() {
|
|
8
|
+
return this;
|
|
9
|
+
}
|
|
10
|
+
FakeRawDriver.use = use;
|
|
11
|
+
FakeRawDriver.all = use;
|
|
12
|
+
FakeRawDriver.get = use;
|
|
13
|
+
FakeRawDriver.patch = use;
|
|
14
|
+
FakeRawDriver.post = use;
|
|
15
|
+
FakeRawDriver.put = use;
|
|
16
|
+
FakeRawDriver.head = use;
|
|
17
|
+
FakeRawDriver.delete = use;
|
|
18
|
+
FakeRawDriver.options = use;
|
|
19
|
+
return FakeRawDriver;
|
|
20
|
+
}
|
|
21
|
+
app() {
|
|
22
|
+
const app = FakeAdapter.createFakeRawDriver();
|
|
23
|
+
return {
|
|
24
|
+
app,
|
|
25
|
+
callback() {
|
|
26
|
+
return app;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
multipart(options) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
statics(endpoint, options) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
bodyParser(type) {
|
|
37
|
+
return () => { };
|
|
38
|
+
}
|
|
39
|
+
mapLayers(layers) { }
|
|
40
|
+
mapHandler(handler) {
|
|
41
|
+
return handler;
|
|
42
|
+
}
|
|
43
|
+
useContext() { }
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=FakeAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":"AAOA,MAAM,OAAO,WAAW;IACtB,SAAS,GAAmB,EAAE,CAAC;IAE/B,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;IAED,SAAS,CAAC,MAAuB,IAAG,CAAC;IAErC,UAAU,CAAC,OAAgD;QACzD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU,KAAI,CAAC;CAChB","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformContextHandler, PlatformLayer} from \"@tsed/platform-router\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\nexport class FakeAdapter implements PlatformAdapter<any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n\n mapLayers(layers: PlatformLayer[]) {}\n\n mapHandler(handler: PlatformContextHandler<PlatformContext>) {\n return handler;\n }\n\n useContext() {}\n}\n"]}
|
|
@@ -1,104 +1,69 @@
|
|
|
1
1
|
import { __decorate, __metadata } from "tslib";
|
|
2
|
-
import { Injectable, InjectorService, ProviderScope
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { PlatformApplication } from "./PlatformApplication";
|
|
7
|
-
import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain";
|
|
2
|
+
import { Injectable, InjectorService, ProviderScope } from "@tsed/di";
|
|
3
|
+
import { PlatformRouters } from "@tsed/platform-router";
|
|
4
|
+
import { PlatformApplication } from "./PlatformApplication.js";
|
|
5
|
+
import { PlatformHandler } from "./PlatformHandler.js";
|
|
8
6
|
/**
|
|
9
7
|
* `Platform` is used to provide all routes collected by annotation `@Controller`.
|
|
10
8
|
*
|
|
11
9
|
* @platform
|
|
12
10
|
*/
|
|
13
11
|
let Platform = class Platform {
|
|
14
|
-
|
|
12
|
+
injector;
|
|
13
|
+
platformApplication;
|
|
14
|
+
platformRouters;
|
|
15
|
+
#controllers = new Map();
|
|
16
|
+
constructor(injector, platformApplication, platformRouters) {
|
|
15
17
|
this.injector = injector;
|
|
16
18
|
this.platformApplication = platformApplication;
|
|
17
|
-
this.
|
|
18
|
-
|
|
19
|
-
this.createRouters();
|
|
19
|
+
this.platformRouters = platformRouters;
|
|
20
|
+
platformRouters.prebuild();
|
|
20
21
|
}
|
|
21
22
|
get app() {
|
|
22
23
|
return this.platformApplication;
|
|
23
24
|
}
|
|
24
|
-
get routes() {
|
|
25
|
-
return this._routes;
|
|
26
|
-
}
|
|
27
25
|
addRoutes(routes) {
|
|
28
26
|
routes.forEach((routeSettings) => {
|
|
29
27
|
this.addRoute(routeSettings.route, routeSettings.token);
|
|
30
28
|
});
|
|
31
29
|
}
|
|
32
|
-
addRoute(
|
|
33
|
-
const
|
|
34
|
-
const provider = injector.getProvider(token);
|
|
30
|
+
addRoute(route, token) {
|
|
31
|
+
const provider = this.injector.getProvider(token);
|
|
35
32
|
if (!provider || provider.hasParent()) {
|
|
36
|
-
return;
|
|
33
|
+
return this;
|
|
37
34
|
}
|
|
38
|
-
const
|
|
39
|
-
this.
|
|
40
|
-
route: ctrlPath,
|
|
41
|
-
provider
|
|
42
|
-
});
|
|
43
|
-
this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));
|
|
44
|
-
this._routes = getOperationsRoutes(provider.token, {
|
|
45
|
-
withChildren: true,
|
|
46
|
-
basePath
|
|
47
|
-
}).reduce((routes, operationRoute) => {
|
|
48
|
-
if (injector.hasProvider(token)) {
|
|
49
|
-
const provider = injector.getProvider(operationRoute.token);
|
|
50
|
-
const route = new PlatformRouteDetails({
|
|
51
|
-
...operationRoute,
|
|
52
|
-
provider
|
|
53
|
-
});
|
|
54
|
-
return routes.concat(route);
|
|
55
|
-
}
|
|
56
|
-
return routes;
|
|
57
|
-
}, this._routes);
|
|
35
|
+
const router = this.platformRouters.from(provider.token);
|
|
36
|
+
this.app.use(route, router);
|
|
58
37
|
return this;
|
|
59
38
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
$onInit() {
|
|
71
|
-
this.buildControllers();
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Create routers from the collected controllers.
|
|
75
|
-
* @private
|
|
76
|
-
*/
|
|
77
|
-
createRouters() {
|
|
78
|
-
const { injector } = this;
|
|
79
|
-
injector.getProviders(ProviderType.CONTROLLER).map((provider) => {
|
|
80
|
-
createRouter(injector, provider);
|
|
39
|
+
getLayers() {
|
|
40
|
+
this.#controllers = new Map();
|
|
41
|
+
return this.platformRouters.getLayers(this.app).map((layer) => {
|
|
42
|
+
if (layer.isProvider()) {
|
|
43
|
+
this.#controllers.set(layer.provider.token, {
|
|
44
|
+
route: String(layer.path).split(layer.provider.path)[0],
|
|
45
|
+
provider: layer.provider
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return layer;
|
|
81
49
|
});
|
|
82
50
|
}
|
|
83
51
|
/**
|
|
84
|
-
*
|
|
85
|
-
* @
|
|
52
|
+
* Get all controllers mounted on the application.
|
|
53
|
+
* @returns {RouteController[]}
|
|
86
54
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
injector.getProviders(ProviderType.CONTROLLER).map((provider) => {
|
|
90
|
-
if (!provider.hasParent()) {
|
|
91
|
-
return buildRouter(injector, provider);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
55
|
+
getMountedControllers() {
|
|
56
|
+
return [...this.#controllers.values()];
|
|
94
57
|
}
|
|
95
58
|
};
|
|
96
59
|
Platform = __decorate([
|
|
97
60
|
Injectable({
|
|
98
61
|
scope: ProviderScope.SINGLETON,
|
|
99
|
-
imports: [
|
|
62
|
+
imports: [PlatformHandler]
|
|
100
63
|
}),
|
|
101
|
-
__metadata("design:paramtypes", [InjectorService,
|
|
64
|
+
__metadata("design:paramtypes", [InjectorService,
|
|
65
|
+
PlatformApplication,
|
|
66
|
+
PlatformRouters])
|
|
102
67
|
], Platform);
|
|
103
68
|
export { Platform };
|
|
104
69
|
//# sourceMappingURL=Platform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAAqB,UAAU,EAAE,eAAe,EAAE,aAAa,EAAgB,MAAM,UAAU,CAAC;AACvG,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAElD;;;;GAIG;AAKH,IAAa,QAAQ,GAArB,MAAa,QAAQ;IAIR;IACA;IACA;IALX,YAAY,GAAiC,IAAI,GAAG,EAAE,CAAC;IAEvD,YACW,QAAyB,EACzB,mBAAwC,EACxC,eAAgC;QAFhC,aAAQ,GAAR,QAAQ,CAAiB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAqB;QACxC,oBAAe,GAAf,eAAe,CAAiB;QAEzC,eAAe,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAEM,SAAS,CAAC,MAAe;QAC9B,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,EAAE,EAAE;YAC/B,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAC1D,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,QAAQ,CAAC,KAAa,EAAE,KAAoB;QACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAuB,CAAC;QAExE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,SAAS,EAAE,EAAE;YACrC,OAAO,IAAI,CAAC;SACb;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEzD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAE5B,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,SAAS;QACd,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;QAE9B,OAAO,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YAC5D,IAAI,KAAK,CAAC,UAAU,EAAE,EAAE;gBACtB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE;oBAC1C,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACvD,QAAQ,EAAE,KAAK,CAAC,QAAQ;iBACzB,CAAC,CAAC;aACJ;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACI,qBAAqB;QAC1B,OAAO,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,CAAC;CACF,CAAA;AAzDY,QAAQ;IAJpB,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;QAC9B,OAAO,EAAE,CAAC,eAAe,CAAC;KAC3B,CAAC;qCAKqB,eAAe;QACJ,mBAAmB;QACvB,eAAe;GANhC,QAAQ,CAyDpB;SAzDY,QAAQ","sourcesContent":["import {ControllerProvider, Injectable, InjectorService, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {PlatformRouters} from \"@tsed/platform-router\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformHandler} from \"./PlatformHandler\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformHandler]\n})\nexport class Platform {\n #controllers: Map<string, RouteController> = new Map();\n\n constructor(\n readonly injector: InjectorService,\n readonly platformApplication: PlatformApplication,\n readonly platformRouters: PlatformRouters\n ) {\n platformRouters.prebuild();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(route: string, token: TokenProvider) {\n const provider = this.injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return this;\n }\n\n const router = this.platformRouters.from(provider.token);\n\n this.app.use(route, router);\n\n return this;\n }\n\n public getLayers() {\n this.#controllers = new Map();\n\n return this.platformRouters.getLayers(this.app).map((layer) => {\n if (layer.isProvider()) {\n this.#controllers.set(layer.provider.token, {\n route: String(layer.path).split(layer.provider.path)[0],\n provider: layer.provider\n });\n }\n\n return layer;\n });\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers(): RouteController[] {\n return [...this.#controllers.values()];\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { InjectorService, registerProvider } from "@tsed/di";
|
|
2
|
+
import { FakeAdapter } from "./FakeAdapter.js";
|
|
3
|
+
export class PlatformAdapter {
|
|
4
|
+
/**
|
|
5
|
+
* Load providers in top priority
|
|
6
|
+
*/
|
|
7
|
+
providers;
|
|
8
|
+
/**
|
|
9
|
+
* Called after the injector instantiation
|
|
10
|
+
*/
|
|
11
|
+
onInit;
|
|
12
|
+
beforeLoadRoutes;
|
|
13
|
+
afterLoadRoutes;
|
|
14
|
+
}
|
|
15
|
+
registerProvider({
|
|
16
|
+
provide: PlatformAdapter,
|
|
17
|
+
deps: [InjectorService],
|
|
18
|
+
useClass: FakeAdapter
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=PlatformAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/services/PlatformAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAgB,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAKzE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAE1C,MAAM,OAAgB,eAAe;IACnC;;OAEG;IACH,SAAS,CAAiB;IAC1B;;OAEG;IACH,MAAM,CAAa;IACnB,gBAAgB,CAAsB;IACtC,eAAe,CAAsB;CAsCtC;AAMD,gBAAgB,CAAC;IACf,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,CAAC,eAAe,CAAC;IACvB,QAAQ,EAAE,WAAW;CACtB,CAAC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, registerProvider} from \"@tsed/di\";\nimport {PlatformHandlerMetadata, PlatformLayer} from \"@tsed/platform-router\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {FakeAdapter} from \"./FakeAdapter\";\n\nexport abstract class PlatformAdapter<App = TsED.Application> {\n /**\n * Load providers in top priority\n */\n providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n /**\n * create initial context\n */\n abstract useContext: () => any;\n /**\n * Map router layer to the targeted framework\n */\n abstract mapLayers: (layer: PlatformLayer[]) => void;\n /**\n * Map handler to the targeted framework\n */\n abstract mapHandler: (handler: Function, layer: PlatformHandlerMetadata) => Function;\n\n /**\n * Return the app instance\n */\n abstract app(): {app: App; callback(): (req: IncomingMessage, res: ServerResponse) => void};\n\n /**\n * Return the statics middlewares\n * @param endpoint\n * @param options\n */\n abstract statics(endpoint: string, options: PlatformStaticsOptions): any;\n\n /**\n * Return the multipart middleware\n * @param options\n */\n abstract multipart(options: PlatformMulterSettings): PlatformMulter;\n\n /**\n * Return the body parser for the given\n * @param type\n * @param opts\n */\n abstract bodyParser(type: string, opts?: Record<string, any>): any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App>>;\n}\n\nregisterProvider({\n provide: PlatformAdapter,\n deps: [InjectorService],\n useClass: FakeAdapter\n});\n"]}
|
|
@@ -1,31 +1,43 @@
|
|
|
1
|
-
var PlatformApplication_1;
|
|
2
1
|
import { __decorate, __metadata } from "tslib";
|
|
3
|
-
import { Injectable, ProviderScope } from "@tsed/di";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { PlatformRouter } from "./PlatformRouter";
|
|
2
|
+
import { Injectable, InjectorService, ProviderScope } from "@tsed/di";
|
|
3
|
+
import { PlatformRouter } from "@tsed/platform-router";
|
|
4
|
+
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
7
5
|
/**
|
|
8
6
|
* `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
|
|
9
7
|
*
|
|
10
8
|
* @platform
|
|
11
9
|
*/
|
|
12
|
-
let PlatformApplication =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
let PlatformApplication = class PlatformApplication extends PlatformRouter {
|
|
11
|
+
adapter;
|
|
12
|
+
injector;
|
|
13
|
+
rawApp;
|
|
14
|
+
rawCallback;
|
|
15
|
+
constructor(adapter, injector) {
|
|
16
|
+
super(injector);
|
|
17
|
+
this.adapter = adapter;
|
|
18
|
+
this.injector = injector;
|
|
19
|
+
const { app, callback } = adapter.app();
|
|
20
|
+
this.rawApp = app;
|
|
21
|
+
this.rawCallback = callback;
|
|
19
22
|
}
|
|
20
23
|
getApp() {
|
|
21
|
-
return this.
|
|
24
|
+
return this.rawApp;
|
|
25
|
+
}
|
|
26
|
+
multer(options) {
|
|
27
|
+
return this.adapter.multipart(options);
|
|
28
|
+
}
|
|
29
|
+
callback(req, res) {
|
|
30
|
+
if (req && res) {
|
|
31
|
+
return this.callback()(req, res);
|
|
32
|
+
}
|
|
33
|
+
return this.rawCallback();
|
|
22
34
|
}
|
|
23
35
|
};
|
|
24
|
-
PlatformApplication =
|
|
36
|
+
PlatformApplication = __decorate([
|
|
25
37
|
Injectable({
|
|
26
38
|
scope: ProviderScope.SINGLETON
|
|
27
39
|
}),
|
|
28
|
-
__metadata("design:paramtypes", [
|
|
40
|
+
__metadata("design:paramtypes", [PlatformAdapter, InjectorService])
|
|
29
41
|
], PlatformApplication);
|
|
30
42
|
export { PlatformApplication };
|
|
31
43
|
//# sourceMappingURL=PlatformApplication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAGrD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AASlD;;;;GAIG;AAIH,IAAa,mBAAmB,GAAhC,MAAa,mBAA4C,SAAQ,cAAc;IAI1D;IAAsC;IAHzD,MAAM,CAAM;IACZ,WAAW,CAAY;IAEvB,YAAmB,OAA6B,EAAS,QAAyB;QAChF,KAAK,CAAC,QAAQ,CAAC,CAAC;QADC,YAAO,GAAP,OAAO,CAAsB;QAAS,aAAQ,GAAR,QAAQ,CAAiB;QAEhF,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAEtC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;QAClB,IAAI,CAAC,WAAW,GAAG,QAAQ,CAAC;IAC9B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,MAAM,CAAC,OAA+B;QACpC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC;IAID,QAAQ,CAAC,GAAqB,EAAE,GAAoB;QAClD,IAAI,GAAG,IAAI,GAAG,EAAE;YACd,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;SAClC;QAED,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;CACF,CAAA;AA7BY,mBAAmB;IAH/B,UAAU,CAAC;QACV,KAAK,EAAE,aAAa,CAAC,SAAS;KAC/B,CAAC;qCAK4B,eAAe,EAAwB,eAAe;GAJvE,mBAAmB,CA6B/B;SA7BY,mBAAmB","sourcesContent":["import {Injectable, InjectorService, ProviderScope} from \"@tsed/di\";\nimport {PlatformRouter} from \"@tsed/platform-router\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n export interface Application {}\n }\n}\n\n/**\n * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON\n})\nexport class PlatformApplication<App = TsED.Application> extends PlatformRouter {\n rawApp: App;\n rawCallback: () => any;\n\n constructor(public adapter: PlatformAdapter<App>, public injector: InjectorService) {\n super(injector);\n const {app, callback} = adapter.app();\n\n this.rawApp = app;\n this.rawCallback = callback;\n }\n\n getApp(): App {\n return this.rawApp;\n }\n\n multer(options: PlatformMulterSettings) {\n return this.adapter.multipart(options);\n }\n\n callback(): (req: IncomingMessage, res: ServerResponse) => any;\n callback(req: IncomingMessage, res: ServerResponse): any;\n callback(req?: IncomingMessage, res?: ServerResponse) {\n if (req && res) {\n return this.callback()(req, res);\n }\n\n return this.rawCallback();\n }\n}\n"]}
|