@tsed/common 7.0.0-alpha.2 → 7.0.0-beta.11
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/lib/cjs/builder/PlatformBuilder.js +281 -0
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js +82 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/cjs/config/services/PlatformConfiguration.js +187 -0
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/cjs/constants/routerOptions.js +5 -0
- package/lib/cjs/constants/routerOptions.js.map +1 -0
- package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
- package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/cjs/decorators/multer/multerOptions.js +52 -0
- package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
- package/lib/cjs/decorators/multer/multipartFile.js +78 -0
- package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
- package/lib/cjs/decorators/params/error.js +20 -0
- package/lib/cjs/decorators/params/error.js.map +1 -0
- package/lib/cjs/decorators/params/next.js +21 -0
- package/lib/cjs/decorators/params/next.js.map +1 -0
- package/lib/cjs/decorators/params/request.js +39 -0
- package/lib/cjs/decorators/params/request.js.map +1 -0
- package/lib/cjs/decorators/params/response.js +33 -0
- package/lib/cjs/decorators/params/response.js.map +1 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +27 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/cjs/domain/ControllerProvider.js +51 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/cjs/domain/EndpointMetadata.js +6 -0
- package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
- package/lib/cjs/domain/HandlerMetadata.js +57 -0
- package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
- package/lib/cjs/domain/PlatformContext.js +92 -0
- package/lib/cjs/domain/PlatformContext.js.map +1 -0
- package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/cjs/exports.js +31 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +68 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/AfterInit.js +3 -0
- package/lib/cjs/interfaces/AfterInit.js.map +1 -0
- package/lib/cjs/interfaces/AfterListen.js +3 -0
- package/lib/cjs/interfaces/AfterListen.js.map +1 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/BeforeInit.js +3 -0
- package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
- package/lib/cjs/interfaces/BeforeListen.js +3 -0
- package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/HandlerType.js +17 -0
- package/lib/cjs/interfaces/HandlerType.js.map +1 -0
- package/lib/cjs/interfaces/IncomingEvent.js +3 -0
- package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
- package/lib/cjs/interfaces/OnReady.js +3 -0
- package/lib/cjs/interfaces/OnReady.js.map +1 -0
- package/lib/cjs/interfaces/OnRequest.js +3 -0
- package/lib/cjs/interfaces/OnRequest.js.map +1 -0
- package/lib/cjs/interfaces/OnResponse.js +3 -0
- package/lib/cjs/interfaces/OnResponse.js.map +1 -0
- package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
- package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/cjs/interfaces/Route.js +3 -0
- package/lib/cjs/interfaces/Route.js.map +1 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +67 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FakeAdapter.js +55 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +128 -0
- package/lib/cjs/services/Platform.js.map +1 -0
- package/lib/cjs/services/PlatformAdapter.js +14 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +32 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -0
- package/lib/cjs/services/PlatformHandler.js +235 -0
- package/lib/cjs/services/PlatformHandler.js.map +1 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js +75 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/cjs/services/PlatformRequest.js +138 -0
- package/lib/cjs/services/PlatformRequest.js.map +1 -0
- package/lib/cjs/services/PlatformResponse.js +271 -0
- package/lib/cjs/services/PlatformResponse.js.map +1 -0
- package/lib/cjs/services/PlatformRouter.js +108 -0
- package/lib/cjs/services/PlatformRouter.js.map +1 -0
- package/lib/cjs/services/PlatformTest.js +173 -0
- package/lib/cjs/services/PlatformTest.js.map +1 -0
- package/lib/cjs/utils/__mock__/Test1.js +8 -0
- package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
- package/lib/cjs/utils/__mock__/Test2.js +8 -0
- package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
- package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +12 -0
- package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/Module1.js +19 -0
- package/lib/cjs/utils/__mock__/module1/Module1.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +17 -0
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js +17 -0
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +15 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +12 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/cjs/utils/__mock__/module2/Module2.js +18 -0
- package/lib/cjs/utils/__mock__/module2/Module2.js.map +1 -0
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +12 -0
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/cjs/utils/createContext.js +38 -0
- package/lib/cjs/utils/createContext.js.map +1 -0
- package/lib/cjs/utils/createHandlerMetadata.js +49 -0
- package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
- package/lib/cjs/utils/createHttpServer.js +29 -0
- package/lib/cjs/utils/createHttpServer.js.map +1 -0
- package/lib/cjs/utils/createHttpsServer.js +29 -0
- package/lib/cjs/utils/createHttpsServer.js.map +1 -0
- package/lib/cjs/utils/createInjector.js +46 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +46 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/getStaticsOptions.js +21 -0
- package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
- package/lib/cjs/utils/listenServer.js +21 -0
- package/lib/cjs/utils/listenServer.js.map +1 -0
- package/lib/cjs/utils/mapReturnedResponse.js +15 -0
- package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
- package/lib/cjs/utils/printRoutes.js +36 -0
- package/lib/cjs/utils/printRoutes.js.map +1 -0
- package/lib/cjs/utils/setResponseHeaders.js +35 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
- package/lib/cjs/utils/useCtxHandler.js +15 -0
- package/lib/cjs/utils/useCtxHandler.js.map +1 -0
- package/lib/esm/builder/PlatformBuilder.js +277 -0
- package/lib/esm/builder/PlatformBuilder.js.map +1 -0
- package/lib/esm/builder/PlatformControllerBuilder.js +76 -0
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
- package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/esm/config/services/PlatformConfiguration.js +184 -0
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/esm/constants/routerOptions.js +2 -0
- package/lib/esm/constants/routerOptions.js.map +1 -0
- package/lib/esm/decorators/multer/multerFileSize.js +31 -0
- package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/esm/decorators/multer/multerOptions.js +48 -0
- package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
- package/lib/esm/decorators/multer/multipartFile.js +74 -0
- package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
- package/lib/esm/decorators/params/error.js +16 -0
- package/lib/esm/decorators/params/error.js.map +1 -0
- package/lib/esm/decorators/params/next.js +17 -0
- package/lib/esm/decorators/params/next.js.map +1 -0
- package/lib/esm/decorators/params/request.js +34 -0
- package/lib/esm/decorators/params/request.js.map +1 -0
- package/lib/esm/decorators/params/response.js +28 -0
- package/lib/esm/decorators/params/response.js.map +1 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js +23 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/esm/domain/ControllerProvider.js +47 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/EndpointMetadata.js +2 -0
- package/lib/esm/domain/EndpointMetadata.js.map +1 -0
- package/lib/esm/domain/HandlerMetadata.js +53 -0
- package/lib/esm/domain/HandlerMetadata.js.map +1 -0
- package/lib/esm/domain/PlatformContext.js +88 -0
- package/lib/esm/domain/PlatformContext.js.map +1 -0
- package/lib/esm/domain/PlatformRouteDetails.js +20 -0
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/esm/exports.js +13 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +65 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/AfterInit.js +2 -0
- package/lib/esm/interfaces/AfterInit.js.map +1 -0
- package/lib/esm/interfaces/AfterListen.js +2 -0
- package/lib/esm/interfaces/AfterListen.js.map +1 -0
- package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
- package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeInit.js +2 -0
- package/lib/esm/interfaces/BeforeInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeListen.js +2 -0
- package/lib/esm/interfaces/BeforeListen.js.map +1 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/HandlerType.js +14 -0
- package/lib/esm/interfaces/HandlerType.js.map +1 -0
- package/lib/esm/interfaces/IncomingEvent.js +2 -0
- package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
- package/lib/esm/interfaces/OnReady.js +2 -0
- package/lib/esm/interfaces/OnReady.js.map +1 -0
- package/lib/esm/interfaces/OnRequest.js +2 -0
- package/lib/esm/interfaces/OnRequest.js.map +1 -0
- package/lib/esm/interfaces/OnResponse.js +2 -0
- package/lib/esm/interfaces/OnResponse.js.map +1 -0
- package/lib/esm/interfaces/OnRoutesInit.js +2 -0
- package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
- package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/esm/interfaces/Route.js +2 -0
- package/lib/esm/interfaces/Route.js.map +1 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +63 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FakeAdapter.js +51 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +125 -0
- package/lib/esm/services/Platform.js.map +1 -0
- package/lib/esm/services/PlatformAdapter.js +10 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +29 -0
- package/lib/esm/services/PlatformApplication.js.map +1 -0
- package/lib/esm/services/PlatformHandler.js +232 -0
- package/lib/esm/services/PlatformHandler.js.map +1 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js +72 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/esm/services/PlatformRequest.js +135 -0
- package/lib/esm/services/PlatformRequest.js.map +1 -0
- package/lib/esm/services/PlatformResponse.js +268 -0
- package/lib/esm/services/PlatformResponse.js.map +1 -0
- package/lib/esm/services/PlatformRouter.js +105 -0
- package/lib/esm/services/PlatformRouter.js.map +1 -0
- package/lib/esm/services/PlatformTest.js +168 -0
- package/lib/esm/services/PlatformTest.js.map +1 -0
- package/lib/esm/utils/__mock__/Test1.js +4 -0
- package/lib/esm/utils/__mock__/Test1.js.map +1 -0
- package/lib/esm/utils/__mock__/Test2.js +4 -0
- package/lib/esm/utils/__mock__/Test2.js.map +1 -0
- package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +9 -0
- package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/Module1.js +16 -0
- package/lib/esm/utils/__mock__/module1/Module1.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +14 -0
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/services/M1Service.js +14 -0
- package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +12 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js +9 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/esm/utils/__mock__/module2/Module2.js +15 -0
- package/lib/esm/utils/__mock__/module2/Module2.js.map +1 -0
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +9 -0
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/esm/utils/createContext.js +34 -0
- package/lib/esm/utils/createContext.js.map +1 -0
- package/lib/esm/utils/createHandlerMetadata.js +45 -0
- package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
- package/lib/esm/utils/createHttpServer.js +24 -0
- package/lib/esm/utils/createHttpServer.js.map +1 -0
- package/lib/esm/utils/createHttpsServer.js +24 -0
- package/lib/esm/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/utils/createInjector.js +42 -0
- package/lib/esm/utils/createInjector.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +42 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/getStaticsOptions.js +17 -0
- package/lib/esm/utils/getStaticsOptions.js.map +1 -0
- package/lib/esm/utils/listenServer.js +17 -0
- package/lib/esm/utils/listenServer.js.map +1 -0
- package/lib/esm/utils/mapReturnedResponse.js +11 -0
- package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
- package/lib/esm/utils/printRoutes.js +32 -0
- package/lib/esm/utils/printRoutes.js.map +1 -0
- package/lib/esm/utils/setResponseHeaders.js +31 -0
- package/lib/esm/utils/setResponseHeaders.js.map +1 -0
- package/lib/esm/utils/useCtxHandler.js +11 -0
- package/lib/esm/utils/useCtxHandler.js.map +1 -0
- package/lib/{builder → types/builder}/PlatformBuilder.d.ts +30 -34
- package/lib/types/builder/PlatformControllerBuilder.d.ts +18 -0
- package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +14 -0
- package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
- package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +24 -17
- package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multerFileSize.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multerOptions.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multipartFile.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/error.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/next.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/request.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/response.d.ts +0 -0
- package/lib/{domain → types/domain}/AnyToPromiseWithCtx.d.ts +0 -0
- package/lib/types/domain/ControllerProvider.d.ts +24 -0
- package/lib/types/domain/EndpointMetadata.d.ts +1 -0
- package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
- package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
- package/lib/types/domain/PlatformRouteDetails.d.ts +22 -0
- package/lib/types/exports.d.ts +12 -0
- package/lib/types/index.d.ts +64 -0
- package/lib/{interfaces → types/interfaces}/AfterInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/AfterListen.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/AfterRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeListen.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/HandlerType.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/IncomingEvent.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnReady.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnRequest.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnResponse.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/PlatformRouteOptions.d.ts +5 -3
- package/lib/{interfaces → types/interfaces}/ResponseErrorObject.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/Route.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +8 -3
- package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +6 -0
- package/lib/types/services/FakeAdapter.d.ts +30 -0
- package/lib/{services → types/services}/Platform.d.ts +22 -7
- package/lib/types/services/PlatformAdapter.d.ts +47 -0
- package/lib/{services → types/services}/PlatformApplication.d.ts +3 -3
- package/lib/{services → types/services}/PlatformHandler.d.ts +1 -1
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +10 -0
- package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
- package/lib/{services → types/services}/PlatformResponse.d.ts +10 -10
- package/lib/{services → types/services}/PlatformRouter.d.ts +12 -8
- package/lib/{services → types/services}/PlatformTest.d.ts +6 -5
- package/lib/types/utils/__mock__/Test1.d.ts +3 -0
- package/lib/types/utils/__mock__/Test2.d.ts +3 -0
- package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/Module1.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
- package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +5 -0
- package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +2 -0
- package/lib/types/utils/__mock__/module2/Module2.d.ts +2 -0
- package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
- package/lib/{utils → types/utils}/createContext.d.ts +0 -0
- package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +1 -1
- package/lib/types/utils/createHttpServer.d.ts +4 -0
- package/lib/types/utils/createHttpsServer.d.ts +5 -0
- package/lib/types/utils/createInjector.d.ts +9 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/getStaticsOptions.d.ts +5 -0
- package/lib/types/utils/listenServer.d.ts +7 -0
- package/lib/{utils → types/utils}/mapReturnedResponse.d.ts +0 -0
- package/lib/{utils → types/utils}/printRoutes.d.ts +0 -0
- package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
- package/lib/{utils → types/utils}/useCtxHandler.d.ts +0 -0
- package/package.json +47 -34
- package/readme.md +50 -57
- package/tsconfig.compile.esm.json +13 -0
- package/lib/PlatformModule.d.ts +0 -15
- package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
- package/lib/config/index.d.ts +0 -3
- package/lib/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
- package/lib/config/interfaces/PlatformMulterSettings.d.ts +0 -138
- package/lib/config/interfaces/index.d.ts +0 -84
- package/lib/decorators/httpServer.d.ts +0 -27
- package/lib/decorators/httpsServer.d.ts +0 -27
- package/lib/decorators/index.d.ts +0 -13
- package/lib/decorators/method/acceptMime.d.ts +0 -19
- package/lib/decorators/method/endpointFn.d.ts +0 -8
- package/lib/decorators/method/location.d.ts +0 -1
- package/lib/decorators/method/redirect.d.ts +0 -1
- package/lib/decorators/method/route.d.ts +0 -1
- package/lib/decorators/multer/index.d.ts +0 -3
- package/lib/domain/ControllerProvider.d.ts +0 -53
- package/lib/domain/EndpointMetadata.d.ts +0 -88
- package/lib/domain/PlatformRouteDetails.d.ts +0 -29
- package/lib/domain/index.d.ts +0 -6
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -3651
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3464
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/PathType.d.ts +0 -1
- package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
- package/lib/interfaces/index.d.ts +0 -17
- package/lib/middlewares/bindEndpointMiddleware.d.ts +0 -5
- package/lib/middlewares/index.d.ts +0 -3
- package/lib/registries/ControllerRegistry.d.ts +0 -1
- package/lib/services/FakeRawDriver.d.ts +0 -15
- package/lib/services/index.d.ts +0 -7
- package/lib/utils/createHttpServer.d.ts +0 -3
- package/lib/utils/createHttpsServer.d.ts +0 -3
- package/lib/utils/createInjector.d.ts +0 -2
- package/lib/utils/createPlatformApplication.d.ts +0 -2
- package/lib/utils/getControllerPath.d.ts +0 -2
- package/lib/utils/index.d.ts +0 -8
- package/lib/utils/listenServer.d.ts +0 -10
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlatformTest = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const PlatformBuilder_1 = require("../builder/PlatformBuilder");
|
|
7
|
+
const PlatformContext_1 = require("../domain/PlatformContext");
|
|
8
|
+
const createInjector_1 = require("../utils/createInjector");
|
|
9
|
+
const PlatformApplication_1 = require("./PlatformApplication");
|
|
10
|
+
const getConfiguration_1 = require("../utils/getConfiguration");
|
|
11
|
+
const accepts_1 = tslib_1.__importDefault(require("accepts"));
|
|
12
|
+
/**
|
|
13
|
+
* @platform
|
|
14
|
+
*/
|
|
15
|
+
class PlatformTest extends di_1.DITest {
|
|
16
|
+
static async create(settings = {}) {
|
|
17
|
+
di_1.DITest.injector = PlatformTest.createInjector((0, getConfiguration_1.getConfiguration)(settings));
|
|
18
|
+
await di_1.DITest.createContainer(settings);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a new injector with the right default services
|
|
22
|
+
*/
|
|
23
|
+
static createInjector(settings = {}) {
|
|
24
|
+
return (0, createInjector_1.createInjector)({
|
|
25
|
+
settings: di_1.DITest.configure({ httpPort: false, httpsPort: false, ...settings })
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Load the server silently without listening port and configure it on test profile.
|
|
30
|
+
* @decorator
|
|
31
|
+
* @param mod
|
|
32
|
+
* @param listen
|
|
33
|
+
* @param settings
|
|
34
|
+
* @returns {Promise<void>}
|
|
35
|
+
*/
|
|
36
|
+
static bootstrap(mod, { listen, ...settings } = {}) {
|
|
37
|
+
return async function before() {
|
|
38
|
+
let instance;
|
|
39
|
+
const adapter = settings.platform || settings.adapter || PlatformTest.adapter;
|
|
40
|
+
/* istanbul ignore next */
|
|
41
|
+
if (!adapter) {
|
|
42
|
+
throw new Error("Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?");
|
|
43
|
+
}
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
settings = di_1.DITest.configure(settings);
|
|
46
|
+
settings.adapter = adapter;
|
|
47
|
+
const configuration = (0, getConfiguration_1.getConfiguration)(settings, mod);
|
|
48
|
+
const disableComponentsScan = configuration.disableComponentsScan || !!process.env.WEBPACK;
|
|
49
|
+
if (!disableComponentsScan) {
|
|
50
|
+
const { importProviders } = await Promise.resolve().then(() => tslib_1.__importStar(require("@tsed/components-scan")));
|
|
51
|
+
await importProviders(configuration);
|
|
52
|
+
}
|
|
53
|
+
instance = await PlatformBuilder_1.PlatformBuilder.build(mod, configuration).bootstrap();
|
|
54
|
+
await instance.listen(!!listen);
|
|
55
|
+
// used by inject method
|
|
56
|
+
di_1.DITest.injector = instance.injector;
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* It injects services into the test function where you can alter, spy on, and manipulate them.
|
|
61
|
+
*
|
|
62
|
+
* The inject function has two parameters
|
|
63
|
+
*
|
|
64
|
+
* * an array of Service dependency injection tokens,
|
|
65
|
+
* * a test function whose parameters correspond exactly to each item in the injection token array.
|
|
66
|
+
*
|
|
67
|
+
* @param targets
|
|
68
|
+
* @param func
|
|
69
|
+
*/
|
|
70
|
+
static inject(targets, func) {
|
|
71
|
+
return async () => {
|
|
72
|
+
if (!di_1.DITest.hasInjector()) {
|
|
73
|
+
await PlatformTest.create();
|
|
74
|
+
}
|
|
75
|
+
const injector = di_1.DITest.injector;
|
|
76
|
+
const deps = [];
|
|
77
|
+
for (const target of targets) {
|
|
78
|
+
deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));
|
|
79
|
+
}
|
|
80
|
+
return await func(...deps);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Return the raw application (express or koa).
|
|
85
|
+
* Use this callback with SuperTest.
|
|
86
|
+
*
|
|
87
|
+
* ```typescript
|
|
88
|
+
* let request: SuperTest.SuperTest<SuperTest.Test>;
|
|
89
|
+
* beforeEach(PlatformTest.bootstrap(Server, {
|
|
90
|
+
* mount: {
|
|
91
|
+
* "/rest": [ProductsController]
|
|
92
|
+
* }
|
|
93
|
+
* }));
|
|
94
|
+
* beforeEach(() => {
|
|
95
|
+
* request = SuperTest(PlatformTest.callback());
|
|
96
|
+
* });
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
static callback() {
|
|
100
|
+
var _a;
|
|
101
|
+
return (_a = di_1.DITest.injector.get(PlatformApplication_1.PlatformApplication)) === null || _a === void 0 ? void 0 : _a.callback();
|
|
102
|
+
}
|
|
103
|
+
static createRequest(options = {}) {
|
|
104
|
+
return {
|
|
105
|
+
headers: {},
|
|
106
|
+
get(key) {
|
|
107
|
+
return this.headers[key.toLowerCase()];
|
|
108
|
+
},
|
|
109
|
+
accepts(mime) {
|
|
110
|
+
return (0, accepts_1.default)(this).types([].concat(mime));
|
|
111
|
+
},
|
|
112
|
+
...options
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static createResponse(options = {}) {
|
|
116
|
+
return {
|
|
117
|
+
headers: {},
|
|
118
|
+
locals: {},
|
|
119
|
+
statusCode: 200,
|
|
120
|
+
status(code) {
|
|
121
|
+
this.statusCode = code;
|
|
122
|
+
return this;
|
|
123
|
+
},
|
|
124
|
+
contentType(content) {
|
|
125
|
+
this.set("content-type", content);
|
|
126
|
+
},
|
|
127
|
+
contentLength(content) {
|
|
128
|
+
this.set("content-length", content);
|
|
129
|
+
},
|
|
130
|
+
redirect(status, path) {
|
|
131
|
+
this.statusCode = status;
|
|
132
|
+
this.set("location", path);
|
|
133
|
+
},
|
|
134
|
+
location(path) {
|
|
135
|
+
this.set("location", path);
|
|
136
|
+
},
|
|
137
|
+
get(key) {
|
|
138
|
+
return this.headers[key.toLowerCase()];
|
|
139
|
+
},
|
|
140
|
+
getHeaders() {
|
|
141
|
+
return this.headers;
|
|
142
|
+
},
|
|
143
|
+
set(key, value) {
|
|
144
|
+
this.headers[key.toLowerCase()] = value;
|
|
145
|
+
return this;
|
|
146
|
+
},
|
|
147
|
+
send(data) {
|
|
148
|
+
this.data = data;
|
|
149
|
+
},
|
|
150
|
+
json(data) {
|
|
151
|
+
this.data = data;
|
|
152
|
+
},
|
|
153
|
+
...options
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
static createRequestContext(options = {}) {
|
|
157
|
+
var _a, _b, _c, _d;
|
|
158
|
+
const event = {
|
|
159
|
+
request: ((_a = options === null || options === void 0 ? void 0 : options.request) === null || _a === void 0 ? void 0 : _a.request) || ((_b = options === null || options === void 0 ? void 0 : options.event) === null || _b === void 0 ? void 0 : _b.request) || PlatformTest.createRequest(),
|
|
160
|
+
response: ((_c = options === null || options === void 0 ? void 0 : options.response) === null || _c === void 0 ? void 0 : _c.response) || ((_d = options === null || options === void 0 ? void 0 : options.event) === null || _d === void 0 ? void 0 : _d.response) || PlatformTest.createResponse()
|
|
161
|
+
};
|
|
162
|
+
return new PlatformContext_1.PlatformContext({
|
|
163
|
+
id: "id",
|
|
164
|
+
injector: di_1.DITest.injector,
|
|
165
|
+
logger: di_1.DITest.injector.logger,
|
|
166
|
+
url: "/",
|
|
167
|
+
...options,
|
|
168
|
+
event
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.PlatformTest = PlatformTest;
|
|
173
|
+
//# sourceMappingURL=PlatformTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformTest.js","sourceRoot":"","sources":["../../../src/services/PlatformTest.ts"],"names":[],"mappings":"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","sourcesContent":["import {DITest, DITestOptions, InjectorService} from \"@tsed/di\";\nimport {Type} from \"@tsed/core\";\nimport {PlatformBuilder} from \"../builder/PlatformBuilder\";\nimport {PlatformContext, PlatformContextOptions} from \"../domain/PlatformContext\";\nimport {createInjector} from \"../utils/createInjector\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {getConfiguration} from \"../utils/getConfiguration\";\nimport {PlatformAdapter, PlatformBuilderSettings} from \"./PlatformAdapter\";\nimport accepts from \"accepts\";\n\n/**\n * @platform\n */\nexport class PlatformTest extends DITest {\n public static adapter: Type<PlatformAdapter>;\n\n static async create(settings: DITestOptions = {}) {\n DITest.injector = PlatformTest.createInjector(getConfiguration(settings));\n await DITest.createContainer(settings);\n }\n\n /**\n * Create a new injector with the right default services\n */\n static createInjector(settings: any = {}): InjectorService {\n return createInjector({\n settings: DITest.configure({httpPort: false, httpsPort: false, ...settings})\n });\n }\n\n /**\n * Load the server silently without listening port and configure it on test profile.\n * @decorator\n * @param mod\n * @param listen\n * @param settings\n * @returns {Promise<void>}\n */\n static bootstrap(mod: any, {listen, ...settings}: Partial<PlatformBuilderSettings & {listen: boolean}> = {}): () => Promise<void> {\n return async function before(): Promise<void> {\n let instance: PlatformBuilder;\n const adapter: Type<PlatformAdapter> = settings.platform || settings.adapter || PlatformTest.adapter;\n\n /* istanbul ignore next */\n if (!adapter) {\n throw new Error(\n \"Platform adapter is not specified. Have you added at least `import @tsed/platform-express` (or equivalent) on your Server.ts ?\"\n );\n }\n\n // @ts-ignore\n settings = DITest.configure(settings);\n settings.adapter = adapter as any;\n\n const configuration = getConfiguration(settings, mod);\n const disableComponentsScan = configuration.disableComponentsScan || !!process.env.WEBPACK;\n\n if (!disableComponentsScan) {\n const {importProviders} = await import(\"@tsed/components-scan\");\n await importProviders(configuration);\n }\n\n instance = await PlatformBuilder.build(mod, configuration).bootstrap();\n await instance.listen(!!listen);\n\n // used by inject method\n DITest.injector = instance.injector;\n };\n }\n\n /**\n * It injects services into the test function where you can alter, spy on, and manipulate them.\n *\n * The inject function has two parameters\n *\n * * an array of Service dependency injection tokens,\n * * a test function whose parameters correspond exactly to each item in the injection token array.\n *\n * @param targets\n * @param func\n */\n static inject<T>(targets: any[], func: (...args: any[]) => Promise<T> | T): () => Promise<T> {\n return async (): Promise<T> => {\n if (!DITest.hasInjector()) {\n await PlatformTest.create();\n }\n\n const injector: InjectorService = DITest.injector;\n const deps = [];\n\n for (const target of targets) {\n deps.push(injector.has(target) ? injector.get(target) : await injector.invoke(target));\n }\n\n return await func(...deps);\n };\n }\n\n /**\n * Return the raw application (express or koa).\n * Use this callback with SuperTest.\n *\n * ```typescript\n * let request: SuperTest.SuperTest<SuperTest.Test>;\n * beforeEach(PlatformTest.bootstrap(Server, {\n * mount: {\n * \"/rest\": [ProductsController]\n * }\n * }));\n * beforeEach(() => {\n * request = SuperTest(PlatformTest.callback());\n * });\n * ```\n */\n static callback() {\n return DITest.injector.get<PlatformApplication>(PlatformApplication)?.callback();\n }\n\n static createRequest(options: any = {}): any {\n return {\n headers: {},\n get(key: string) {\n return this.headers[key.toLowerCase()];\n },\n accepts(mime?: string | string[]) {\n return accepts(this).types([].concat(mime as never));\n },\n ...options\n };\n }\n\n static createResponse(options: any = {}): any {\n return {\n headers: {},\n locals: {},\n statusCode: 200,\n status(code: number) {\n this.statusCode = code;\n return this;\n },\n contentType(content: string) {\n this.set(\"content-type\", content);\n },\n contentLength(content: number) {\n this.set(\"content-length\", content);\n },\n redirect(status: number, path: string) {\n this.statusCode = status;\n this.set(\"location\", path);\n },\n location(path: string) {\n this.set(\"location\", path);\n },\n get(key: string) {\n return this.headers[key.toLowerCase()];\n },\n getHeaders() {\n return this.headers;\n },\n set(key: string, value: any) {\n this.headers[key.toLowerCase()] = value;\n return this;\n },\n send(data: any) {\n this.data = data;\n },\n json(data: any) {\n this.data = data;\n },\n ...options\n };\n }\n\n static createRequestContext(options: Partial<PlatformContextOptions & any> = {}) {\n const event = {\n request: options?.request?.request || options?.event?.request || PlatformTest.createRequest(),\n response: options?.response?.response || options?.event?.response || PlatformTest.createResponse()\n };\n\n return new PlatformContext({\n id: \"id\",\n injector: DITest.injector,\n logger: DITest.injector.logger,\n url: \"/\",\n ...options,\n event\n });\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Test1.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test1.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value1 = \"value\";\n\nexport class Test1 {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Test2.js","sourceRoot":"","sources":["../../../../src/utils/__mock__/Test2.ts"],"names":[],"mappings":";;;AAAa,QAAA,MAAM,GAAG,OAAO,CAAC;AAE9B,MAAa,KAAK;CAAG;AAArB,sBAAqB","sourcesContent":["export const value2 = \"value\";\n\nexport class Test2 {}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TestCtrl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
let TestCtrl = class TestCtrl {
|
|
7
|
+
};
|
|
8
|
+
TestCtrl = tslib_1.__decorate([
|
|
9
|
+
(0, di_1.Controller)("/root")
|
|
10
|
+
], TestCtrl);
|
|
11
|
+
exports.TestCtrl = TestCtrl;
|
|
12
|
+
//# sourceMappingURL=TestCtrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestCtrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/controllers/rest/TestCtrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,IAAA,eAAU,EAAC,OAAO,CAAC;GACP,QAAQ,CAAG;AAAX,4BAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/root\")\nexport class TestCtrl {}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Module1 = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const SubModule_1 = require("./submodule/SubModule");
|
|
6
|
+
const di_1 = require("@tsed/di");
|
|
7
|
+
const M1Ctrl1_1 = require("./controllers/M1Ctrl1");
|
|
8
|
+
let Module1 = class Module1 {
|
|
9
|
+
};
|
|
10
|
+
Module1 = tslib_1.__decorate([
|
|
11
|
+
(0, di_1.Module)({
|
|
12
|
+
mount: {
|
|
13
|
+
"/m1": [M1Ctrl1_1.M1Ctrl1]
|
|
14
|
+
},
|
|
15
|
+
imports: [SubModule_1.SubModule]
|
|
16
|
+
})
|
|
17
|
+
], Module1);
|
|
18
|
+
exports.Module1 = Module1;
|
|
19
|
+
//# sourceMappingURL=Module1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Module1.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module1/Module1.ts"],"names":[],"mappings":";;;;AAAA,qDAAgD;AAChD,iCAAgC;AAChC,mDAA8C;AAQ9C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,KAAK,EAAE,CAAC,iBAAO,CAAC;SACjB;QACD,OAAO,EAAE,CAAC,qBAAS,CAAC;KACrB,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {SubModule} from \"./submodule/SubModule\";\nimport {Module} from \"@tsed/di\";\nimport {M1Ctrl1} from \"./controllers/M1Ctrl1\";\n\n@Module({\n mount: {\n \"/m1\": [M1Ctrl1]\n },\n imports: [SubModule]\n})\nexport class Module1 {}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.M1Ctrl1 = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const M1Service_1 = require("../services/M1Service");
|
|
7
|
+
let M1Ctrl1 = class M1Ctrl1 {
|
|
8
|
+
constructor(service) {
|
|
9
|
+
this.service = service;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
M1Ctrl1 = tslib_1.__decorate([
|
|
13
|
+
(0, di_1.Controller)("/m1"),
|
|
14
|
+
tslib_1.__metadata("design:paramtypes", [M1Service_1.M1Service])
|
|
15
|
+
], M1Ctrl1);
|
|
16
|
+
exports.M1Ctrl1 = M1Ctrl1;
|
|
17
|
+
//# sourceMappingURL=M1Ctrl1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"M1Ctrl1.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/controllers/M1Ctrl1.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,qDAAgD;AAGhD,IAAa,OAAO,GAApB,MAAa,OAAO;IAClB,YAAmB,OAAkB;QAAlB,YAAO,GAAP,OAAO,CAAW;IAAG,CAAC;CAC1C,CAAA;AAFY,OAAO;IADnB,IAAA,eAAU,EAAC,KAAK,CAAC;6CAEY,qBAAS;GAD1B,OAAO,CAEnB;AAFY,0BAAO","sourcesContent":["import {Controller} from \"@tsed/di\";\nimport {M1Service} from \"../services/M1Service\";\n\n@Controller(\"/m1\")\nexport class M1Ctrl1 {\n constructor(public service: M1Service) {}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.M1Service = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const SubService_1 = require("../submodule/SubService");
|
|
7
|
+
let M1Service = class M1Service {
|
|
8
|
+
constructor(subService) {
|
|
9
|
+
this.subService = subService;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
M1Service = tslib_1.__decorate([
|
|
13
|
+
(0, di_1.Injectable)(),
|
|
14
|
+
tslib_1.__metadata("design:paramtypes", [SubService_1.SubService])
|
|
15
|
+
], M1Service);
|
|
16
|
+
exports.M1Service = M1Service;
|
|
17
|
+
//# sourceMappingURL=M1Service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"M1Service.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/services/M1Service.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AACpC,wDAAmD;AAGnD,IAAa,SAAS,GAAtB,MAAa,SAAS;IACpB,YAAmB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;CAC9C,CAAA;AAFY,SAAS;IADrB,IAAA,eAAU,GAAE;6CAEoB,uBAAU;GAD9B,SAAS,CAErB;AAFY,8BAAS","sourcesContent":["import {Injectable} from \"@tsed/di\";\nimport {SubService} from \"../submodule/SubService\";\n\n@Injectable()\nexport class M1Service {\n constructor(public subService: SubService) {}\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubModule = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const SubService_1 = require("./SubService");
|
|
7
|
+
let SubModule = class SubModule {
|
|
8
|
+
};
|
|
9
|
+
SubModule = tslib_1.__decorate([
|
|
10
|
+
(0, di_1.Module)({
|
|
11
|
+
imports: [SubService_1.SubService]
|
|
12
|
+
})
|
|
13
|
+
], SubModule);
|
|
14
|
+
exports.SubModule = SubModule;
|
|
15
|
+
//# sourceMappingURL=SubModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubModule.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubModule.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,6CAAwC;AAKxC,IAAa,SAAS,GAAtB,MAAa,SAAS;CAAG,CAAA;AAAZ,SAAS;IAHrB,IAAA,WAAM,EAAC;QACN,OAAO,EAAE,CAAC,uBAAU,CAAC;KACtB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {SubService} from \"./SubService\";\n\n@Module({\n imports: [SubService]\n})\nexport class SubModule {}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
let SubService = class SubService {
|
|
7
|
+
};
|
|
8
|
+
SubService = tslib_1.__decorate([
|
|
9
|
+
(0, di_1.Injectable)()
|
|
10
|
+
], SubService);
|
|
11
|
+
exports.SubService = SubService;
|
|
12
|
+
//# sourceMappingURL=SubService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubService.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module1/submodule/SubService.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,UAAU,GAAvB,MAAa,UAAU;CAAG,CAAA;AAAb,UAAU;IADtB,IAAA,eAAU,GAAE;GACA,UAAU,CAAG;AAAb,gCAAU","sourcesContent":["import {Injectable} from \"@tsed/di\";\n\n@Injectable()\nexport class SubService {}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Module2 = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const M2Ctrl_1 = require("./controllers/M2Ctrl");
|
|
7
|
+
let Module2 = class Module2 {
|
|
8
|
+
};
|
|
9
|
+
Module2 = tslib_1.__decorate([
|
|
10
|
+
(0, di_1.Module)({
|
|
11
|
+
mount: {
|
|
12
|
+
"/mod2": [M2Ctrl_1.M2Ctrl]
|
|
13
|
+
},
|
|
14
|
+
imports: []
|
|
15
|
+
})
|
|
16
|
+
], Module2);
|
|
17
|
+
exports.Module2 = Module2;
|
|
18
|
+
//# sourceMappingURL=Module2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Module2.js","sourceRoot":"","sources":["../../../../../src/utils/__mock__/module2/Module2.ts"],"names":[],"mappings":";;;;AAAA,iCAAgC;AAChC,iDAA4C;AAQ5C,IAAa,OAAO,GAApB,MAAa,OAAO;CAAG,CAAA;AAAV,OAAO;IANnB,IAAA,WAAM,EAAC;QACN,KAAK,EAAE;YACL,OAAO,EAAE,CAAC,eAAM,CAAC;SAClB;QACD,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,OAAO,CAAG;AAAV,0BAAO","sourcesContent":["import {Module} from \"@tsed/di\";\nimport {M2Ctrl} from \"./controllers/M2Ctrl\";\n\n@Module({\n mount: {\n \"/mod2\": [M2Ctrl]\n },\n imports: []\n})\nexport class Module2 {}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.M2Ctrl = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
let M2Ctrl = class M2Ctrl {
|
|
7
|
+
};
|
|
8
|
+
M2Ctrl = tslib_1.__decorate([
|
|
9
|
+
(0, di_1.Controller)("/m2")
|
|
10
|
+
], M2Ctrl);
|
|
11
|
+
exports.M2Ctrl = M2Ctrl;
|
|
12
|
+
//# sourceMappingURL=M2Ctrl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"M2Ctrl.js","sourceRoot":"","sources":["../../../../../../src/utils/__mock__/module2/controllers/M2Ctrl.ts"],"names":[],"mappings":";;;;AAAA,iCAAoC;AAGpC,IAAa,MAAM,GAAnB,MAAa,MAAM;CAAG,CAAA;AAAT,MAAM;IADlB,IAAA,eAAU,EAAC,KAAK,CAAC;GACL,MAAM,CAAG;AAAT,wBAAM","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/m2\")\nexport class M2Ctrl {}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createContext = void 0;
|
|
4
|
+
const PlatformContext_1 = require("../domain/PlatformContext");
|
|
5
|
+
const PlatformRequest_1 = require("../services/PlatformRequest");
|
|
6
|
+
const PlatformResponse_1 = require("../services/PlatformResponse");
|
|
7
|
+
const uuid_1 = require("uuid");
|
|
8
|
+
const defaultReqIdBuilder = (req) => req.get("x-request-id") || (0, uuid_1.v4)().replace(/-/gi, "");
|
|
9
|
+
/**
|
|
10
|
+
* Create the TsED context to wrap request, response, injector, etc...
|
|
11
|
+
* @param injector
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
14
|
+
function createContext(injector) {
|
|
15
|
+
var _a, _b;
|
|
16
|
+
const ResponseKlass = (_a = injector.getProvider(PlatformResponse_1.PlatformResponse)) === null || _a === void 0 ? void 0 : _a.useClass;
|
|
17
|
+
const RequestKlass = (_b = injector.getProvider(PlatformRequest_1.PlatformRequest)) === null || _b === void 0 ? void 0 : _b.useClass;
|
|
18
|
+
const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger || {};
|
|
19
|
+
return async (event) => {
|
|
20
|
+
const ctx = new PlatformContext_1.PlatformContext({
|
|
21
|
+
event,
|
|
22
|
+
id: reqIdBuilder(event.request),
|
|
23
|
+
logger: injector.logger,
|
|
24
|
+
...loggerOptions,
|
|
25
|
+
injector,
|
|
26
|
+
ResponseKlass,
|
|
27
|
+
RequestKlass
|
|
28
|
+
});
|
|
29
|
+
ctx.response.onEnd(async () => {
|
|
30
|
+
await ctx.emit("$onResponse", ctx);
|
|
31
|
+
await ctx.destroy();
|
|
32
|
+
});
|
|
33
|
+
await ctx.emit("$onRequest", ctx);
|
|
34
|
+
return ctx;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
exports.createContext = createContext;
|
|
38
|
+
//# sourceMappingURL=createContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAC1D,iEAA4D;AAC5D,mEAA8D;AAE9D,+BAAwB;AAExB,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,IAAA,SAAE,GAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAE7F;;;;GAIG;AACH,SAAgB,aAAa,CAAC,QAAyB;;IACrD,MAAM,aAAa,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,mCAAgB,CAAC,0CAAE,QAAQ,CAAC;IACvE,MAAM,YAAY,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,iCAAe,CAAC,0CAAE,QAAQ,CAAC;IACrE,MAAM,EAAC,YAAY,GAAG,mBAAmB,EAAE,GAAG,aAAa,EAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;IAE9F,OAAO,KAAK,EAAE,KAAoB,EAA4B,EAAE;QAC9D,MAAM,GAAG,GAAG,IAAI,iCAAe,CAAC;YAC9B,KAAK;YACL,EAAE,EAAE,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM;YACvB,GAAG,aAAa;YAChB,QAAQ;YACR,aAAa;YACb,YAAY;SACb,CAAC,CAAC;QAEH,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;YAC5B,MAAM,GAAG,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;YACnC,MAAM,GAAG,CAAC,OAAO,EAAE,CAAC;QACtB,CAAC,CAAC,CAAC;QAEH,MAAM,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;AACJ,CAAC;AAzBD,sCAyBC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\nimport {v4} from \"uuid\";\n\nconst defaultReqIdBuilder = (req: any) => req.get(\"x-request-id\") || v4().replace(/-/gi, \"\");\n\n/**\n * Create the TsED context to wrap request, response, injector, etc...\n * @param injector\n * @ignore\n */\nexport function createContext(injector: InjectorService) {\n const ResponseKlass = injector.getProvider(PlatformResponse)?.useClass;\n const RequestKlass = injector.getProvider(PlatformRequest)?.useClass;\n const {reqIdBuilder = defaultReqIdBuilder, ...loggerOptions} = injector.settings.logger || {};\n\n return async (event: IncomingEvent): Promise<PlatformContext> => {\n const ctx = new PlatformContext({\n event,\n id: reqIdBuilder(event.request),\n logger: injector.logger,\n ...loggerOptions,\n injector,\n ResponseKlass,\n RequestKlass\n });\n\n ctx.response.onEnd(async () => {\n await ctx.emit(\"$onResponse\", ctx);\n await ctx.destroy();\n });\n\n await ctx.emit(\"$onRequest\", ctx);\n\n return ctx;\n };\n}\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHandlerMetadata = void 0;
|
|
4
|
+
const schema_1 = require("@tsed/schema");
|
|
5
|
+
const HandlerMetadata_1 = require("../domain/HandlerMetadata");
|
|
6
|
+
const HandlerType_1 = require("../interfaces/HandlerType");
|
|
7
|
+
function isMetadata(input) {
|
|
8
|
+
return input instanceof HandlerMetadata_1.HandlerMetadata;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
function createHandlerMetadata(injector, obj, routeOptions = {}) {
|
|
14
|
+
if (isMetadata(obj)) {
|
|
15
|
+
return obj;
|
|
16
|
+
}
|
|
17
|
+
let options;
|
|
18
|
+
if (obj instanceof schema_1.EndpointMetadata) {
|
|
19
|
+
const provider = injector.getProvider(routeOptions.token);
|
|
20
|
+
options = {
|
|
21
|
+
token: provider.token,
|
|
22
|
+
target: provider.useClass,
|
|
23
|
+
scope: provider.scope,
|
|
24
|
+
type: HandlerType_1.HandlerType.ENDPOINT,
|
|
25
|
+
propertyKey: obj.propertyKey
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
const provider = injector.getProvider(obj);
|
|
30
|
+
if (provider) {
|
|
31
|
+
options = {
|
|
32
|
+
token: provider.token,
|
|
33
|
+
target: provider.useClass,
|
|
34
|
+
scope: provider.scope,
|
|
35
|
+
type: HandlerType_1.HandlerType.MIDDLEWARE,
|
|
36
|
+
propertyKey: "use"
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
options = {
|
|
41
|
+
target: obj
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
options.routeOptions = routeOptions;
|
|
46
|
+
return new HandlerMetadata_1.HandlerMetadata(options);
|
|
47
|
+
}
|
|
48
|
+
exports.createHandlerMetadata = createHandlerMetadata;
|
|
49
|
+
//# sourceMappingURL=createHandlerMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandlerMetadata.js","sourceRoot":"","sources":["../../../src/utils/createHandlerMetadata.ts"],"names":[],"mappings":";;;AACA,yCAA8C;AAC9C,+DAAkF;AAClF,2DAAsD;AAGtD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,KAAK,YAAY,iCAAe,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,QAAyB,EACzB,GAA2B,EAC3B,eAA6C,EAAE;IAE/C,IAAI,UAAU,CAAC,GAAG,CAAC,EAAE;QACnB,OAAO,GAAsB,CAAC;KAC/B;IAED,IAAI,OAA+B,CAAC;IAEpC,IAAI,GAAG,YAAY,yBAAgB,EAAE;QACnC,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,YAAY,CAAC,KAAK,CAAE,CAAC;QAE3D,OAAO,GAAG;YACR,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;YACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,IAAI,EAAE,yBAAW,CAAC,QAAQ;YAC1B,WAAW,EAAE,GAAG,CAAC,WAAW;SAC7B,CAAC;KACH;SAAM;QACL,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAE3C,IAAI,QAAQ,EAAE;YACZ,OAAO,GAAG;gBACR,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,MAAM,EAAE,QAAQ,CAAC,QAAQ;gBACzB,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,IAAI,EAAE,yBAAW,CAAC,UAAU;gBAC5B,WAAW,EAAE,KAAK;aACnB,CAAC;SACH;aAAM;YACL,OAAO,GAAG;gBACR,MAAM,EAAE,GAAG;aACZ,CAAC;SACH;KACF;IAED,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC;IAEpC,OAAO,IAAI,iCAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC;AA1CD,sDA0CC","sourcesContent":["import {InjectorService} from \"@tsed/di\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {HandlerMetadata, HandlerMetadataOptions} from \"../domain/HandlerMetadata\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nfunction isMetadata(input: any) {\n return input instanceof HandlerMetadata;\n}\n\n/**\n * @ignore\n */\nexport function createHandlerMetadata(\n injector: InjectorService,\n obj: any | EndpointMetadata,\n routeOptions: PlatformRouteWithoutHandlers = {}\n): HandlerMetadata {\n if (isMetadata(obj)) {\n return obj as HandlerMetadata;\n }\n\n let options: HandlerMetadataOptions;\n\n if (obj instanceof EndpointMetadata) {\n const provider = injector.getProvider(routeOptions.token)!;\n\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.ENDPOINT,\n propertyKey: obj.propertyKey\n };\n } else {\n const provider = injector.getProvider(obj);\n\n if (provider) {\n options = {\n token: provider.token,\n target: provider.useClass,\n scope: provider.scope,\n type: HandlerType.MIDDLEWARE,\n propertyKey: \"use\"\n };\n } else {\n options = {\n target: obj\n };\n }\n }\n\n options.routeOptions = routeOptions;\n\n return new HandlerMetadata(options);\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHttpServer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
7
|
+
const http_1 = tslib_1.__importDefault(require("http"));
|
|
8
|
+
const listenServer_1 = require("./listenServer");
|
|
9
|
+
function createHttpServer(injector, requestListener) {
|
|
10
|
+
const { settings } = injector;
|
|
11
|
+
const httpPort = settings.getRaw("httpPort");
|
|
12
|
+
const httpOptions = settings.getRaw("httpOptions");
|
|
13
|
+
const server = httpPort !== false ? http_1.default.createServer(httpOptions, requestListener) : null;
|
|
14
|
+
injector.addProvider(http_1.default.Server, {
|
|
15
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
16
|
+
useValue: server
|
|
17
|
+
});
|
|
18
|
+
injector.invoke(http_1.default.Server);
|
|
19
|
+
if (server) {
|
|
20
|
+
const hostInfo = (0, core_1.getHostInfoFromPort)("http", httpPort);
|
|
21
|
+
return async () => {
|
|
22
|
+
const resolvedHostInfo = await (0, listenServer_1.listenServer)(injector, server, hostInfo);
|
|
23
|
+
settings.setRaw("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
|
|
24
|
+
return server;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.createHttpServer = createHttpServer;
|
|
29
|
+
//# sourceMappingURL=createHttpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":";;;;AAAA,iCAAwD;AACxD,qCAA+C;AAC/C,wDAAwB;AACxB,iDAA4C;AAE5C,SAAgB,gBAAgB,CAAC,QAAyB,EAAE,eAAqC;IAC/F,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAC7C,MAAM,WAAW,GAAG,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAEnD,MAAM,MAAM,GAAG,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,cAAI,CAAC,YAAY,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE3F,QAAQ,CAAC,WAAW,CAAC,cAAI,CAAC,MAAM,EAAE;QAChC,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,cAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,IAAA,0BAAmB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEvD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,IAAA,2BAAY,EAAC,QAAQ,EAAE,MAAqB,EAAE,QAAQ,CAAC,CAAC;YACvF,QAAQ,CAAC,MAAM,CAAC,UAAU,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACpF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC;AAvBD,4CAuBC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService, requestListener: Http.RequestListener) {\n const {settings} = injector;\n const httpPort = settings.getRaw(\"httpPort\");\n const httpOptions = settings.getRaw(\"httpOptions\");\n\n const server = httpPort !== false ? Http.createServer(httpOptions, requestListener) : null;\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Http.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"http\", httpPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Http.Server, hostInfo);\n settings.setRaw(\"httpPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHttpsServer = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
7
|
+
const https_1 = tslib_1.__importDefault(require("https"));
|
|
8
|
+
const listenServer_1 = require("./listenServer");
|
|
9
|
+
function createHttpsServer(injector, requestListener) {
|
|
10
|
+
const { settings } = injector;
|
|
11
|
+
const httpsPort = settings.getRaw("httpsPort");
|
|
12
|
+
const httpsOptions = settings.getRaw("httpsOptions");
|
|
13
|
+
const server = httpsPort !== false ? https_1.default.createServer(httpsOptions, requestListener) : null;
|
|
14
|
+
injector.addProvider(https_1.default.Server, {
|
|
15
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
16
|
+
useValue: server
|
|
17
|
+
});
|
|
18
|
+
injector.invoke(https_1.default.Server);
|
|
19
|
+
if (server) {
|
|
20
|
+
const hostInfo = (0, core_1.getHostInfoFromPort)("https", httpsPort);
|
|
21
|
+
return async () => {
|
|
22
|
+
const resolvedHostInfo = await (0, listenServer_1.listenServer)(injector, server, hostInfo);
|
|
23
|
+
settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
|
|
24
|
+
return server;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.createHttpsServer = createHttpsServer;
|
|
29
|
+
//# sourceMappingURL=createHttpsServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":";;;;AAAA,iCAAwD;AACxD,qCAA+C;AAC/C,0DAA0B;AAE1B,iDAA4C;AAE5C,SAAgB,iBAAiB,CAAC,QAAyB,EAAE,eAAsC;IACjG,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAC/C,MAAM,YAAY,GAAG,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAErD,MAAM,MAAM,GAAG,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,eAAK,CAAC,YAAY,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9F,QAAQ,CAAC,WAAW,CAAC,eAAK,CAAC,MAAM,EAAE;QACjC,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,eAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,MAAM,EAAE;QACV,MAAM,QAAQ,GAAG,IAAA,0BAAmB,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEzD,OAAO,KAAK,IAAI,EAAE;YAChB,MAAM,gBAAgB,GAAG,MAAM,IAAA,2BAAY,EAAC,QAAQ,EAAE,MAAsB,EAAE,QAAQ,CAAC,CAAC;YACxF,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,gBAAgB,CAAC,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,CAAC,CAAC;YACrF,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;KACH;AACH,CAAC;AAvBD,8CAuBC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService, requestListener?: Http.RequestListener) {\n const {settings} = injector;\n const httpsPort = settings.getRaw(\"httpsPort\");\n const httpsOptions = settings.getRaw(\"httpsOptions\");\n\n const server = httpsPort !== false ? Https.createServer(httpsOptions, requestListener) : null;\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(Https.Server);\n\n if (server) {\n const hostInfo = getHostInfoFromPort(\"https\", httpsPort);\n\n return async () => {\n const resolvedHostInfo = await listenServer(injector, server as Https.Server, hostInfo);\n settings.setRaw(\"httpsPort\", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);\n return server;\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createInjector = void 0;
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const logger_1 = require("@tsed/logger");
|
|
6
|
+
const core_1 = require("@tsed/core");
|
|
7
|
+
const PlatformConfiguration_1 = require("../config/services/PlatformConfiguration");
|
|
8
|
+
const PlatformHandler_1 = require("../services/PlatformHandler");
|
|
9
|
+
const PlatformResponse_1 = require("../services/PlatformResponse");
|
|
10
|
+
const PlatformRouter_1 = require("../services/PlatformRouter");
|
|
11
|
+
const PlatformApplication_1 = require("../services/PlatformApplication");
|
|
12
|
+
const Platform_1 = require("../services/Platform");
|
|
13
|
+
const PlatformRequest_1 = require("../services/PlatformRequest");
|
|
14
|
+
const PlatformAdapter_1 = require("../services/PlatformAdapter");
|
|
15
|
+
logger_1.$log.name = "TSED";
|
|
16
|
+
const DEFAULT_PROVIDERS = [
|
|
17
|
+
{ provide: PlatformHandler_1.PlatformHandler },
|
|
18
|
+
{ provide: PlatformResponse_1.PlatformResponse },
|
|
19
|
+
{ provide: PlatformRequest_1.PlatformRequest },
|
|
20
|
+
{ provide: PlatformRouter_1.PlatformRouter },
|
|
21
|
+
{ provide: PlatformApplication_1.PlatformApplication },
|
|
22
|
+
{ provide: Platform_1.Platform }
|
|
23
|
+
];
|
|
24
|
+
function createInjector({ adapter, settings = {} }) {
|
|
25
|
+
const injector = new di_1.InjectorService();
|
|
26
|
+
injector.addProvider(PlatformConfiguration_1.PlatformConfiguration);
|
|
27
|
+
injector.settings = injector.invoke(PlatformConfiguration_1.PlatformConfiguration);
|
|
28
|
+
injector.logger = logger_1.$log;
|
|
29
|
+
injector.settings.set(settings);
|
|
30
|
+
if (adapter) {
|
|
31
|
+
injector.addProvider(PlatformAdapter_1.PlatformAdapter, {
|
|
32
|
+
useClass: adapter
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
injector.invoke(PlatformAdapter_1.PlatformAdapter);
|
|
36
|
+
(0, di_1.setLoggerLevel)(injector);
|
|
37
|
+
const instance = injector.get(PlatformAdapter_1.PlatformAdapter);
|
|
38
|
+
instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];
|
|
39
|
+
(0, core_1.toMap)(instance.providers, "provide").forEach((provider, token) => {
|
|
40
|
+
injector.addProvider(token, provider);
|
|
41
|
+
});
|
|
42
|
+
injector.invoke(PlatformApplication_1.PlatformApplication);
|
|
43
|
+
return injector;
|
|
44
|
+
}
|
|
45
|
+
exports.createInjector = createInjector;
|
|
46
|
+
//# sourceMappingURL=createInjector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":";;;AAAA,iCAAuE;AACvE,yCAAkC;AAClC,qCAAuC;AACvC,oFAA+E;AAC/E,iEAA4D;AAC5D,mEAA8D;AAC9D,+DAA0D;AAC1D,yEAAoE;AACpE,mDAA8C;AAC9C,iEAA4D;AAC5D,iEAA4D;AAE5D,aAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,iCAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,mCAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,iCAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,+BAAc,EAAC;IACzB,EAAC,OAAO,EAAE,yCAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,mBAAQ,EAAC;CACpB,CAAC;AAOF,SAAgB,cAAc,CAAC,EAAC,OAAO,EAAE,QAAQ,GAAG,EAAE,EAAwB;IAC5E,MAAM,QAAQ,GAAG,IAAI,oBAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,6CAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,6CAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,aAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,IAAI,OAAO,EAAE;QACX,QAAQ,CAAC,WAAW,CAAC,iCAAe,EAAE;YACpC,QAAQ,EAAE,OAAO;SAClB,CAAC,CAAC;KACJ;IAED,QAAQ,CAAC,MAAM,CAAC,iCAAe,CAAC,CAAC;IAEjC,IAAA,mBAAc,EAAC,QAAQ,CAAC,CAAC;IAEzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAkB,iCAAe,CAAE,CAAC;IAEjE,QAAQ,CAAC,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;IAEnE,IAAA,YAAK,EAAoB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QAClF,QAAQ,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,CAAC,yCAAmB,CAAC,CAAC;IAErC,OAAO,QAAQ,CAAC;AAClB,CAAC;AA7BD,wCA6BC","sourcesContent":["import {InjectorService, ProviderOpts, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap, Type} from \"@tsed/core\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\nimport {PlatformHandler} from \"../services/PlatformHandler\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\nimport {PlatformRouter} from \"../services/PlatformRouter\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {Platform} from \"../services/Platform\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformAdapter} from \"../services/PlatformAdapter\";\n\n$log.name = \"TSED\";\n\nconst DEFAULT_PROVIDERS = [\n {provide: PlatformHandler},\n {provide: PlatformResponse},\n {provide: PlatformRequest},\n {provide: PlatformRouter},\n {provide: PlatformApplication},\n {provide: Platform}\n];\n\ninterface CreateInjectorOptions {\n adapter?: Type<PlatformAdapter<any, any>>;\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({adapter, settings = {}}: CreateInjectorOptions) {\n const injector = new InjectorService();\n injector.addProvider(PlatformConfiguration);\n\n injector.settings = injector.invoke(PlatformConfiguration);\n injector.logger = $log;\n injector.settings.set(settings);\n\n if (adapter) {\n injector.addProvider(PlatformAdapter, {\n useClass: adapter\n });\n }\n\n injector.invoke(PlatformAdapter);\n\n setLoggerLevel(injector);\n\n const instance = injector.get<PlatformAdapter>(PlatformAdapter)!;\n\n instance.providers = [...DEFAULT_PROVIDERS, ...instance.providers];\n\n toMap<any, ProviderOpts>(instance.providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
|