@tsed/common 7.0.0-alpha.1 → 7.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/builder/PlatformBuilder.js +275 -0
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js +85 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/cjs/config/index.js +7 -0
- package/lib/cjs/config/index.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/EndpointDirectoriesSettings.js +3 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.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/interfaces/index.js +8 -0
- package/lib/cjs/config/interfaces/index.js.map +1 -0
- package/lib/cjs/config/services/PlatformConfiguration.js +181 -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/httpServer.js +32 -0
- package/lib/cjs/decorators/httpServer.js.map +1 -0
- package/lib/cjs/decorators/httpsServer.js +32 -0
- package/lib/cjs/decorators/httpsServer.js.map +1 -0
- package/lib/cjs/decorators/index.js +26 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/cjs/decorators/method/acceptMime.js +28 -0
- package/lib/cjs/decorators/method/acceptMime.js.map +1 -0
- package/lib/cjs/decorators/multer/index.js +7 -0
- package/lib/cjs/decorators/multer/index.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 +70 -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/domain/index.js +10 -0
- package/lib/cjs/domain/index.js.map +1 -0
- package/lib/cjs/index.js +34 -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/PathType.js +3 -0
- package/lib/cjs/interfaces/PathType.js.map +1 -0
- package/lib/cjs/interfaces/PlatformAdapter.js +3 -0
- package/lib/cjs/interfaces/PlatformAdapter.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/interfaces/index.js +21 -0
- package/lib/cjs/interfaces/index.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 +55 -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/middlewares/index.js +7 -0
- package/lib/cjs/middlewares/index.js.map +1 -0
- package/lib/cjs/services/FakeRawDriver.js +26 -0
- package/lib/cjs/services/FakeRawDriver.js.map +1 -0
- package/lib/cjs/services/Platform.js +107 -0
- package/lib/cjs/services/Platform.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +34 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -0
- package/lib/cjs/services/PlatformHandler.js +233 -0
- package/lib/cjs/services/PlatformHandler.js.map +1 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js +34 -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 +126 -0
- package/lib/cjs/services/PlatformRouter.js.map +1 -0
- package/lib/cjs/services/PlatformTest.js +166 -0
- package/lib/cjs/services/PlatformTest.js.map +1 -0
- package/lib/cjs/services/index.js +12 -0
- package/lib/cjs/services/index.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 +34 -0
- package/lib/cjs/utils/createHttpServer.js.map +1 -0
- package/lib/cjs/utils/createHttpsServer.js +34 -0
- package/lib/cjs/utils/createHttpsServer.js.map +1 -0
- package/lib/cjs/utils/createInjector.js +38 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +42 -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/index.js +11 -0
- package/lib/cjs/utils/index.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 +271 -0
- package/lib/esm/builder/PlatformBuilder.js.map +1 -0
- package/lib/esm/builder/PlatformControllerBuilder.js +79 -0
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/esm/config/index.js +4 -0
- package/lib/esm/config/index.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/EndpointDirectoriesSettings.js +2 -0
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.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/interfaces/index.js +5 -0
- package/lib/esm/config/interfaces/index.js.map +1 -0
- package/lib/esm/config/services/PlatformConfiguration.js +178 -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/httpServer.js +28 -0
- package/lib/esm/decorators/httpServer.js.map +1 -0
- package/lib/esm/decorators/httpsServer.js +28 -0
- package/lib/esm/decorators/httpsServer.js.map +1 -0
- package/lib/esm/decorators/index.js +14 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/method/acceptMime.js +24 -0
- package/lib/esm/decorators/method/acceptMime.js.map +1 -0
- package/lib/esm/decorators/multer/index.js +4 -0
- package/lib/esm/decorators/multer/index.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 +67 -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/domain/index.js +7 -0
- package/lib/esm/domain/index.js.map +1 -0
- package/lib/esm/index.js +28 -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/PathType.js +2 -0
- package/lib/esm/interfaces/PathType.js.map +1 -0
- package/lib/esm/interfaces/PlatformAdapter.js +2 -0
- package/lib/esm/interfaces/PlatformAdapter.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/interfaces/index.js +18 -0
- package/lib/esm/interfaces/index.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 +52 -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/middlewares/index.js +4 -0
- package/lib/esm/middlewares/index.js.map +1 -0
- package/lib/esm/services/FakeRawDriver.js +22 -0
- package/lib/esm/services/FakeRawDriver.js.map +1 -0
- package/lib/esm/services/Platform.js +104 -0
- package/lib/esm/services/Platform.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +31 -0
- package/lib/esm/services/PlatformApplication.js.map +1 -0
- package/lib/esm/services/PlatformHandler.js +230 -0
- package/lib/esm/services/PlatformHandler.js.map +1 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js +31 -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 +123 -0
- package/lib/esm/services/PlatformRouter.js.map +1 -0
- package/lib/esm/services/PlatformTest.js +162 -0
- package/lib/esm/services/PlatformTest.js.map +1 -0
- package/lib/esm/services/index.js +9 -0
- package/lib/esm/services/index.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 +29 -0
- package/lib/esm/utils/createHttpServer.js.map +1 -0
- package/lib/esm/utils/createHttpsServer.js +29 -0
- package/lib/esm/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/utils/createInjector.js +34 -0
- package/lib/esm/utils/createInjector.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +38 -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/index.js +8 -0
- package/lib/esm/utils/index.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 +25 -30
- package/lib/types/builder/PlatformControllerBuilder.d.ts +17 -0
- package/lib/{config → types/config}/index.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/EndpointDirectoriesSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -16
- package/lib/{config → types/config}/interfaces/PlatformMulterSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
- package/lib/{config → types/config}/interfaces/index.d.ts +17 -2
- package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +13 -11
- package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
- package/lib/{decorators → types/decorators}/httpServer.d.ts +1 -0
- package/lib/{decorators → types/decorators}/httpsServer.d.ts +1 -0
- package/lib/{decorators → types/decorators}/index.d.ts +1 -5
- package/lib/{decorators → types/decorators}/method/acceptMime.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/index.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/{domain → types/domain}/EndpointMetadata.d.ts +3 -42
- package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
- package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
- package/lib/{domain → types/domain}/PlatformRouteDetails.d.ts +4 -10
- package/lib/{domain → types/domain}/index.d.ts +0 -0
- package/lib/{index.d.ts → types/index.d.ts} +2 -3
- 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}/PathType.d.ts +0 -0
- package/lib/types/interfaces/PlatformAdapter.d.ts +19 -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/{interfaces → types/interfaces}/index.d.ts +1 -2
- package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +0 -0
- package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/bindEndpointMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/index.d.ts +0 -1
- package/lib/{services → types/services}/FakeRawDriver.d.ts +0 -0
- package/lib/{services → types/services}/Platform.d.ts +12 -6
- package/lib/{services → types/services}/PlatformApplication.d.ts +0 -0
- package/lib/{services → types/services}/PlatformHandler.d.ts +3 -8
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -0
- package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
- package/lib/{services → types/services}/PlatformResponse.d.ts +4 -4
- package/lib/{services → types/services}/PlatformRouter.d.ts +4 -3
- package/lib/{services → types/services}/PlatformTest.d.ts +7 -6
- package/lib/{services → types/services}/index.d.ts +1 -1
- package/lib/{utils → types/utils}/createContext.d.ts +0 -0
- package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +0 -0
- package/lib/types/utils/createHttpServer.d.ts +4 -0
- package/lib/types/utils/createHttpsServer.d.ts +4 -0
- package/lib/types/utils/createInjector.d.ts +7 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/getStaticsOptions.d.ts +5 -0
- package/lib/{utils → types/utils}/index.d.ts +0 -1
- 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 +29 -24
- package/tsconfig.compile.esm.json +23 -0
- package/lib/PlatformModule.d.ts +0 -15
- package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
- package/lib/decorators/class/controller.d.ts +0 -43
- 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 -128
- package/lib/domain/ControllerProvider.d.ts +0 -54
- package/lib/index.js +0 -3990
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3870
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
- package/lib/middlewares/PlatformLogMiddleware.d.ts +0 -44
- package/lib/registries/ControllerRegistry.d.ts +0 -1
- package/lib/services/ConverterService.d.ts +0 -27
- 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/listenServer.d.ts +0 -10
|
@@ -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 uuidv4 = require("uuid").v4;
|
|
8
|
+
const defaultReqIdBuilder = (req) => req.get("x-request-id") || uuidv4().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;AAG9D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;AAClC,MAAM,mBAAmB,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAEjG;;;;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\";\n\nconst uuidv4 = require(\"uuid\").v4;\nconst defaultReqIdBuilder = (req: any) => req.get(\"x-request-id\") || uuidv4().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 EndpointMetadata_1 = require("../domain/EndpointMetadata");
|
|
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 EndpointMetadata_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,iEAA4D;AAC5D,+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,mCAAgB,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 \"../domain/EndpointMetadata\";\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,34 @@
|
|
|
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 = (0, tslib_1.__importDefault)(require("http"));
|
|
8
|
+
const httpServer_1 = require("../decorators/httpServer");
|
|
9
|
+
const listenServer_1 = require("./listenServer");
|
|
10
|
+
function createHttpServer(injector, requestListener) {
|
|
11
|
+
const { settings } = injector;
|
|
12
|
+
const httpPort = settings.getRaw("httpPort");
|
|
13
|
+
const httpOptions = settings.getRaw("httpOptions");
|
|
14
|
+
const server = httpPort !== false ? http_1.default.createServer(httpOptions, requestListener) : null;
|
|
15
|
+
injector.addProvider(httpServer_1.HttpServer, {
|
|
16
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
17
|
+
useValue: server
|
|
18
|
+
});
|
|
19
|
+
injector.addProvider(http_1.default.Server, {
|
|
20
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
21
|
+
useValue: server
|
|
22
|
+
});
|
|
23
|
+
injector.invoke(httpServer_1.HttpServer);
|
|
24
|
+
injector.invoke(http_1.default.Server);
|
|
25
|
+
if (httpPort !== false) {
|
|
26
|
+
const hostInfo = (0, core_1.getHostInfoFromPort)("http", httpPort);
|
|
27
|
+
return async () => {
|
|
28
|
+
const resolvedHostInfo = await (0, listenServer_1.listenServer)(injector, server, hostInfo);
|
|
29
|
+
settings.setRaw("httpPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.createHttpServer = createHttpServer;
|
|
34
|
+
//# 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,6DAAwB;AACxB,yDAAoD;AACpD,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,uBAAU,EAAE;QAC/B,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,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,uBAAU,CAAC,CAAC;IAC5B,QAAQ,CAAC,MAAM,CAAC,cAAI,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,QAAQ,KAAK,KAAK,EAAE;QACtB,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;QACtF,CAAC,CAAC;KACH;AACH,CAAC;AA5BD,4CA4BC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Http from \"http\";\nimport {HttpServer} from \"../decorators/httpServer\";\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(HttpServer, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.addProvider(Http.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(HttpServer);\n injector.invoke(Http.Server);\n\n if (httpPort !== false) {\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 };\n }\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 = (0, tslib_1.__importDefault)(require("https"));
|
|
8
|
+
const httpsServer_1 = require("../decorators/httpsServer");
|
|
9
|
+
const listenServer_1 = require("./listenServer");
|
|
10
|
+
function createHttpsServer(injector, requestListener) {
|
|
11
|
+
const { settings } = injector;
|
|
12
|
+
const httpsPort = settings.getRaw("httpsPort");
|
|
13
|
+
const httpsOptions = settings.getRaw("httpsOptions");
|
|
14
|
+
const server = httpsPort !== false ? https_1.default.createServer(httpsOptions, requestListener) : null;
|
|
15
|
+
injector.addProvider(httpsServer_1.HttpsServer, {
|
|
16
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
17
|
+
useValue: server
|
|
18
|
+
});
|
|
19
|
+
injector.addProvider(https_1.default.Server, {
|
|
20
|
+
scope: di_1.ProviderScope.SINGLETON,
|
|
21
|
+
useValue: server
|
|
22
|
+
});
|
|
23
|
+
injector.invoke(httpsServer_1.HttpsServer);
|
|
24
|
+
injector.invoke(https_1.default.Server);
|
|
25
|
+
if (httpsPort !== false) {
|
|
26
|
+
const hostInfo = (0, core_1.getHostInfoFromPort)("https", httpsPort);
|
|
27
|
+
return async () => {
|
|
28
|
+
const resolvedHostInfo = await (0, listenServer_1.listenServer)(injector, server, hostInfo);
|
|
29
|
+
settings.setRaw("httpsPort", `${resolvedHostInfo.address}:${resolvedHostInfo.port}`);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.createHttpsServer = createHttpsServer;
|
|
34
|
+
//# 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,+DAA0B;AAE1B,2DAAsD;AACtD,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,yBAAW,EAAE;QAChC,KAAK,EAAE,kBAAa,CAAC,SAAS;QAC9B,QAAQ,EAAE,MAAM;KACjB,CAAC,CAAC;IAEH,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,yBAAW,CAAC,CAAC;IAC7B,QAAQ,CAAC,MAAM,CAAC,eAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,IAAI,SAAS,KAAK,KAAK,EAAE;QACvB,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;QACvF,CAAC,CAAC;KACH;AACH,CAAC;AA5BD,8CA4BC","sourcesContent":["import {InjectorService, ProviderScope} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\nimport Https from \"https\";\nimport Http from \"http\";\nimport {HttpsServer} from \"../decorators/httpsServer\";\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(HttpsServer, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.addProvider(Https.Server, {\n scope: ProviderScope.SINGLETON,\n useValue: server\n });\n\n injector.invoke(HttpsServer);\n injector.invoke(Https.Server);\n\n if (httpsPort !== false) {\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 };\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
logger_1.$log.name = "TSED";
|
|
15
|
+
const DEFAULT_PROVIDERS = [
|
|
16
|
+
{ provide: PlatformHandler_1.PlatformHandler },
|
|
17
|
+
{ provide: PlatformResponse_1.PlatformResponse },
|
|
18
|
+
{ provide: PlatformRequest_1.PlatformRequest },
|
|
19
|
+
{ provide: PlatformRouter_1.PlatformRouter },
|
|
20
|
+
{ provide: PlatformApplication_1.PlatformApplication },
|
|
21
|
+
{ provide: Platform_1.Platform }
|
|
22
|
+
];
|
|
23
|
+
function createInjector({ providers = [], settings = {} }) {
|
|
24
|
+
const injector = new di_1.InjectorService();
|
|
25
|
+
injector.addProvider(PlatformConfiguration_1.PlatformConfiguration);
|
|
26
|
+
injector.settings = injector.invoke(PlatformConfiguration_1.PlatformConfiguration);
|
|
27
|
+
injector.logger = logger_1.$log;
|
|
28
|
+
injector.settings.set(settings);
|
|
29
|
+
(0, di_1.setLoggerLevel)(injector);
|
|
30
|
+
providers = [...DEFAULT_PROVIDERS, ...providers];
|
|
31
|
+
(0, core_1.toMap)(providers, "provide").forEach((provider, token) => {
|
|
32
|
+
injector.addProvider(token, provider);
|
|
33
|
+
});
|
|
34
|
+
injector.invoke(PlatformApplication_1.PlatformApplication);
|
|
35
|
+
return injector;
|
|
36
|
+
}
|
|
37
|
+
exports.createInjector = createInjector;
|
|
38
|
+
//# sourceMappingURL=createInjector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":";;;AAAA,iCAAoE;AACpE,yCAAkC;AAClC,qCAAiC;AACjC,oFAA+E;AAC/E,iEAA4D;AAC5D,mEAA8D;AAC9D,+DAA0D;AAC1D,yEAAoE;AACpE,mDAA8C;AAC9C,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,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAwB;IACnF,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,IAAA,mBAAc,EAAC,QAAQ,CAAC,CAAC;IAEzB,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;IAEjD,IAAA,YAAK,EAAiB,SAAS,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACtE,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;AAnBD,wCAmBC","sourcesContent":["import {InjectorService, IProvider, setLoggerLevel} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport {toMap} 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\";\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 providers?: IProvider[];\n settings?: Partial<TsED.Configuration>;\n}\n\nexport function createInjector({providers = [], 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 setLoggerLevel(injector);\n\n providers = [...DEFAULT_PROVIDERS, ...providers];\n\n toMap<any, IProvider>(providers, \"provide\").forEach((provider, token) => {\n injector.addProvider(token, provider);\n });\n\n injector.invoke(PlatformApplication);\n\n return injector;\n}\n"]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConfiguration = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
function getConfiguration(configuration = {}, module = null) {
|
|
7
|
+
const store = module ? core_1.Store.from(module).get("configuration") || {} : {};
|
|
8
|
+
const env = configuration.env || store.env || process.env.NODE_ENV || core_1.Env.DEV;
|
|
9
|
+
const config = {
|
|
10
|
+
exclude: ["**/*.spec.ts", "**/*.spec.js"],
|
|
11
|
+
componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
|
|
12
|
+
env,
|
|
13
|
+
httpPort: 8080,
|
|
14
|
+
httpsPort: false,
|
|
15
|
+
...store,
|
|
16
|
+
...configuration,
|
|
17
|
+
scopes: {
|
|
18
|
+
[di_1.ProviderType.CONTROLLER]: di_1.ProviderScope.SINGLETON,
|
|
19
|
+
...store.scopes,
|
|
20
|
+
...configuration.scopes
|
|
21
|
+
},
|
|
22
|
+
mount: store.mount || configuration.mount
|
|
23
|
+
? (0, core_1.deepMerge)(store.mount || {}, configuration.mount || {})
|
|
24
|
+
: {
|
|
25
|
+
"/rest": "${rootDir}/controllers/**/*.ts"
|
|
26
|
+
},
|
|
27
|
+
logger: {
|
|
28
|
+
debug: false,
|
|
29
|
+
level: env === core_1.Env.TEST ? "off" : "info",
|
|
30
|
+
logRequest: true,
|
|
31
|
+
...store.logger,
|
|
32
|
+
...configuration.logger,
|
|
33
|
+
jsonIndentation: process.env.NODE_ENV === core_1.Env.PROD ? 0 : 2
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
|
|
37
|
+
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
38
|
+
}
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
exports.getConfiguration = getConfiguration;
|
|
42
|
+
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":";;;AAAA,qCAAuD;AACvD,iCAAqD;AAErD,SAAgB,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,YAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,GAAG,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,UAAG,CAAC,GAAG,CAAC;IAEvF,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,CAAC,cAAc,EAAE,cAAc,CAAC;QACzC,cAAc,EAAE,CAAC,wBAAwB,EAAE,6BAA6B,EAAE,gCAAgC,CAAC;QAC3G,GAAG;QACH,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,KAAK;QAChB,GAAG,KAAK;QACR,GAAG,aAAa;QAChB,MAAM,EAAE;YACN,CAAC,iBAAY,CAAC,UAAU,CAAC,EAAE,kBAAa,CAAC,SAAS;YAClD,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;SACxB;QACD,KAAK,EACH,KAAK,CAAC,KAAK,IAAI,aAAa,CAAC,KAAK;YAChC,CAAC,CAAC,IAAA,gBAAS,EAAC,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,aAAa,CAAC,KAAK,IAAI,EAAE,CAAC;YACzD,CAAC,CAAC;gBACE,OAAO,EAAE,gCAAgC;aAC1C;QACP,MAAM,EAAE;YACN,KAAK,EAAE,KAAK;YACZ,KAAK,EAAE,GAAG,KAAK,UAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,UAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;IAEF,IAAI,CAAC,aAAa,CAAC,qBAAqB,IAAI,KAAK,CAAC,cAAc,IAAI,aAAa,CAAC,cAAc,EAAE;QAChG,MAAM,CAAC,cAAc,GAAG,CAAC,GAAG,KAAK,CAAC,cAAc,EAAE,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;KACpF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAtCD,4CAsCC","sourcesContent":["import {deepMerge, Env, Store, Type} from \"@tsed/core\";\nimport {ProviderScope, ProviderType} from \"@tsed/di\";\n\nexport function getConfiguration(configuration: any = {}, module: Type<any> | null = null) {\n const store = module ? Store.from(module).get(\"configuration\") || {} : {};\n const env = configuration.env || store.env || (process.env.NODE_ENV as Env) || Env.DEV;\n\n const config = {\n exclude: [\"**/*.spec.ts\", \"**/*.spec.js\"],\n componentsScan: [\"${rootDir}/mvc/**/*.ts\", \"${rootDir}/services/**/*.ts\", \"${rootDir}/middlewares/**/*.ts\"],\n env,\n httpPort: 8080,\n httpsPort: false,\n ...store,\n ...configuration,\n scopes: {\n [ProviderType.CONTROLLER]: ProviderScope.SINGLETON,\n ...store.scopes,\n ...configuration.scopes\n },\n mount:\n store.mount || configuration.mount\n ? deepMerge(store.mount || {}, configuration.mount || {})\n : {\n \"/rest\": \"${rootDir}/controllers/**/*.ts\"\n },\n logger: {\n debug: false,\n level: env === Env.TEST ? \"off\" : \"info\",\n logRequest: true,\n ...store.logger,\n ...configuration.logger,\n jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2\n }\n };\n\n if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {\n config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];\n }\n\n return config;\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getStaticsOptions = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
function mapOptions(options) {
|
|
6
|
+
const opts = typeof options === "string" ? { root: options } : options;
|
|
7
|
+
return {
|
|
8
|
+
...opts,
|
|
9
|
+
hook: (0, core_1.getValue)(opts, "hook", "$afterRoutesInit")
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function getStaticsOptions(statics) {
|
|
13
|
+
return Object.entries(statics || {}).reduce((statics, [path, items]) => {
|
|
14
|
+
[].concat(items).forEach((options) => {
|
|
15
|
+
statics.push({ path, options: mapOptions(options) });
|
|
16
|
+
});
|
|
17
|
+
return statics;
|
|
18
|
+
}, []);
|
|
19
|
+
}
|
|
20
|
+
exports.getStaticsOptions = getStaticsOptions;
|
|
21
|
+
//# sourceMappingURL=getStaticsOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStaticsOptions.js","sourceRoot":"","sources":["../../../src/utils/getStaticsOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAoC;AAGpC,SAAS,UAAU,CAAC,OAAY;IAC9B,MAAM,IAAI,GAA2B,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC,CAAC,CAAC,OAAO,CAAC;IAC7F,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,IAAA,eAAQ,EAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAAiC;IACjE,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;QACrE,EAAE,CAAC,MAAM,CAAC,KAAY,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC1C,OAAO,CAAC,IAAI,CAAC,EAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,CAAC;QACrD,CAAC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAuD,CAAC,CAAC;AAC9D,CAAC;AARD,8CAQC","sourcesContent":["import {getValue} from \"@tsed/core\";\nimport {PlatformStaticsOptions, PlatformStaticsSettings} from \"../config/interfaces/PlatformStaticsSettings\";\n\nfunction mapOptions(options: any): any {\n const opts: PlatformStaticsOptions = typeof options === \"string\" ? {root: options} : options;\n return {\n ...opts,\n hook: getValue(opts, \"hook\", \"$afterRoutesInit\")\n };\n}\n\nexport function getStaticsOptions(statics?: PlatformStaticsSettings): {path: string; options: PlatformStaticsOptions}[] {\n return Object.entries(statics || {}).reduce((statics, [path, items]) => {\n [].concat(items as any).forEach((options) => {\n statics.push({path, options: mapOptions(options)});\n });\n\n return statics;\n }, [] as {path: string; options: PlatformStaticsOptions}[]);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./createInjector"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./createHttpServer"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./createHttpsServer"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./printRoutes"), exports);
|
|
8
|
+
(0, tslib_1.__exportStar)(require("./listenServer"), exports);
|
|
9
|
+
(0, tslib_1.__exportStar)(require("./createContext"), exports);
|
|
10
|
+
(0, tslib_1.__exportStar)(require("./useCtxHandler"), exports);
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,gEAAiC;AACjC,kEAAmC;AACnC,mEAAoC;AACpC,6DAA8B;AAC9B,8DAA+B;AAC/B,+DAAgC;AAChC,+DAAgC","sourcesContent":["export * from \"./createInjector\";\nexport * from \"./createHttpServer\";\nexport * from \"./createHttpsServer\";\nexport * from \"./printRoutes\";\nexport * from \"./listenServer\";\nexport * from \"./createContext\";\nexport * from \"./useCtxHandler\";\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listenServer = void 0;
|
|
4
|
+
function listenServer(injector, server, hostInfo) {
|
|
5
|
+
const { protocol, address, port } = hostInfo;
|
|
6
|
+
const url = `${protocol}://${address}:${port}`;
|
|
7
|
+
injector.logger.debug(`Start server on ${url}`);
|
|
8
|
+
const promise = new Promise((resolve, reject) => {
|
|
9
|
+
server.on("listening", resolve);
|
|
10
|
+
server.on("error", reject);
|
|
11
|
+
}).then(() => {
|
|
12
|
+
const port = server.address().port;
|
|
13
|
+
const info = { ...hostInfo, port };
|
|
14
|
+
injector.logger.info(`Listen server on ${info.toString()}`);
|
|
15
|
+
return info;
|
|
16
|
+
});
|
|
17
|
+
server.listen(port, address);
|
|
18
|
+
return promise;
|
|
19
|
+
}
|
|
20
|
+
exports.listenServer = listenServer;
|
|
21
|
+
//# sourceMappingURL=listenServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../src/utils/listenServer.ts"],"names":[],"mappings":";;;AAMA,SAAgB,YAAY,CAC1B,QAAyB,EACzB,MAAsD,EACtD,QAAgD;IAEhD,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAC3C,MAAM,GAAG,GAAG,GAAG,QAAQ,MAAM,OAAO,IAAI,IAAI,EAAE,CAAC;IAC/C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,MAAM,IAAI,GAAI,MAAM,CAAC,OAAO,EAAU,CAAC,IAAI,CAAC;QAC5C,MAAM,IAAI,GAAG,EAAC,GAAG,QAAQ,EAAE,IAAI,EAAC,CAAC;QAEjC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAE5D,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAEpC,OAAO,OAAO,CAAC;AACjB,CAAC;AAxBD,oCAwBC","sourcesContent":["import type Http from \"http\";\nimport type Https from \"https\";\nimport type Http2 from \"http2\";\nimport {InjectorService} from \"@tsed/di\";\nimport {getHostInfoFromPort} from \"@tsed/core\";\n\nexport function listenServer(\n injector: InjectorService,\n server: Http.Server | Https.Server | Http2.Http2Server,\n hostInfo: ReturnType<typeof getHostInfoFromPort>\n): Promise<ReturnType<typeof getHostInfoFromPort>> {\n const {protocol, address, port} = hostInfo;\n const url = `${protocol}://${address}:${port}`;\n injector.logger.debug(`Start server on ${url}`);\n\n const promise = new Promise((resolve, reject) => {\n server.on(\"listening\", resolve);\n server.on(\"error\", reject);\n }).then(() => {\n const port = (server.address() as any).port;\n const info = {...hostInfo, port};\n\n injector.logger.info(`Listen server on ${info.toString()}`);\n\n return info;\n });\n\n server.listen(port, address as any);\n\n return promise;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapReturnedResponse = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
function mapReturnedResponse({ use, collection, ...options }) {
|
|
8
|
+
return {
|
|
9
|
+
...options,
|
|
10
|
+
type: options.type || use,
|
|
11
|
+
collectionType: options.collectionType || collection
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
exports.mapReturnedResponse = mapReturnedResponse;
|
|
15
|
+
//# sourceMappingURL=mapReturnedResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapReturnedResponse.js","sourceRoot":"","sources":["../../../src/utils/mapReturnedResponse.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,SAAgB,mBAAmB,CAAC,EAAC,GAAG,EAAE,UAAU,EAAE,GAAG,OAAO,EAAM;IACpE,OAAO;QACL,GAAG,OAAO;QACV,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,GAAG;QACzB,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,UAAU;KACrD,CAAC;AACJ,CAAC;AAND,kDAMC","sourcesContent":["/**\n * @ignore\n */\nexport function mapReturnedResponse({use, collection, ...options}: any): any {\n return {\n ...options,\n type: options.type || use,\n collectionType: options.collectionType || collection\n };\n}\n"]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.printRoutes = void 0;
|
|
4
|
+
const logger_1 = require("@tsed/logger");
|
|
5
|
+
function printRoutes(routes) {
|
|
6
|
+
const mapColor = {
|
|
7
|
+
GET: "green",
|
|
8
|
+
POST: "yellow",
|
|
9
|
+
PUT: "blue",
|
|
10
|
+
DELETE: "red",
|
|
11
|
+
PATCH: "magenta",
|
|
12
|
+
ALL: "cyan"
|
|
13
|
+
};
|
|
14
|
+
const list = routes.map((route) => {
|
|
15
|
+
const obj = route.toJSON();
|
|
16
|
+
const method = obj.method.toUpperCase();
|
|
17
|
+
obj.method = {
|
|
18
|
+
length: method.length,
|
|
19
|
+
toString: () => {
|
|
20
|
+
return (0, logger_1.colorize)(method, mapColor[method]);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
return obj;
|
|
24
|
+
});
|
|
25
|
+
const str = logger_1.$log.drawTable(list, {
|
|
26
|
+
padding: 1,
|
|
27
|
+
header: {
|
|
28
|
+
method: "Method",
|
|
29
|
+
url: "Endpoint",
|
|
30
|
+
name: "Class method"
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return "\n" + str.trim();
|
|
34
|
+
}
|
|
35
|
+
exports.printRoutes = printRoutes;
|
|
36
|
+
//# sourceMappingURL=printRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":";;;AAAA,yCAA4C;AAG5C,SAAgB,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;KACZ,CAAC;IAEF,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;QAC3B,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAExC,GAAG,CAAC,MAAM,GAAG;YACX,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,QAAQ,EAAE,GAAG,EAAE;gBACb,OAAO,IAAA,iBAAQ,EAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;SACK,CAAC;QAET,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,aAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC;AAlCD,kCAkCC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\"\n };\n\n const list = routes.map((route) => {\n const obj = route.toJSON();\n const method = obj.method.toUpperCase();\n\n obj.method = {\n length: method.length,\n toString: () => {\n return colorize(method, mapColor[method]);\n }\n } as any;\n\n return obj;\n });\n\n const str = $log.drawTable(list, {\n padding: 1,\n header: {\n method: \"Method\",\n url: \"Endpoint\",\n name: \"Class method\"\n }\n });\n\n return \"\\n\" + str.trim();\n}\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setResponseHeaders = void 0;
|
|
4
|
+
function mergeHeaders(specHeaders, headers) {
|
|
5
|
+
return Object.entries(specHeaders).reduce((headers, [key, item]) => {
|
|
6
|
+
key = key.toLowerCase();
|
|
7
|
+
return {
|
|
8
|
+
...headers,
|
|
9
|
+
[key]: headers[key] === undefined ? String(item.example) : headers[key]
|
|
10
|
+
};
|
|
11
|
+
}, headers);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
function setResponseHeaders(ctx) {
|
|
17
|
+
const { response, endpoint } = ctx;
|
|
18
|
+
const { operation } = endpoint;
|
|
19
|
+
if (response.isDone()) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
if (!response.hasStatus()) {
|
|
23
|
+
// apply status only if the isn't already modified
|
|
24
|
+
response.status(operation.getStatus());
|
|
25
|
+
}
|
|
26
|
+
const statusCode = response.statusCode;
|
|
27
|
+
const headers = operation.getHeadersOf(response.statusCode);
|
|
28
|
+
const mergedHeaders = mergeHeaders(headers, response.getHeaders());
|
|
29
|
+
response.setHeaders(mergedHeaders);
|
|
30
|
+
if (operation.isRedirection(statusCode)) {
|
|
31
|
+
response.redirect(statusCode, String(mergedHeaders["location"]));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.setResponseHeaders = setResponseHeaders;
|
|
35
|
+
//# sourceMappingURL=setResponseHeaders.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setResponseHeaders.js","sourceRoot":"","sources":["../../../src/utils/setResponseHeaders.ts"],"names":[],"mappings":";;;AAIA,SAAS,YAAY,CAAC,WAA2D,EAAE,OAAoC;IACrH,OAAO,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE;QACjE,GAAG,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC;QACxB,OAAO;YACL,GAAG,OAAO;YACV,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC;SACxE,CAAC;IACJ,CAAC,EAAE,OAAO,CAAC,CAAC;AACd,CAAC;AAED;;GAEG;AACH,SAAgB,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;IAEnE,QAAQ,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAEnC,IAAI,SAAS,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE;QACvC,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;KAClE;AACH,CAAC;AAtBD,gDAsBC","sourcesContent":["import {JsonHeader} from \"@tsed/schema\";\nimport {PlatformContext} from \"../domain/PlatformContext\";\nimport {HeaderValue} from \"../services/PlatformResponse\";\n\nfunction mergeHeaders(specHeaders: Record<string, JsonHeader & {example: string}>, headers: Record<string, HeaderValue>) {\n return Object.entries(specHeaders).reduce((headers, [key, item]) => {\n key = key.toLowerCase();\n return {\n ...headers,\n [key]: headers[key] === undefined ? String(item.example) : headers[key]\n };\n }, headers);\n}\n\n/**\n * @ignore\n */\nexport function setResponseHeaders(ctx: PlatformContext) {\n const {response, endpoint} = ctx;\n const {operation} = endpoint;\n\n if (response.isDone()) {\n return;\n }\n\n if (!response.hasStatus()) {\n // apply status only if the isn't already modified\n response.status(operation.getStatus());\n }\n\n const statusCode = response.statusCode;\n const headers = operation.getHeadersOf(response.statusCode);\n const mergedHeaders = mergeHeaders(headers, response.getHeaders());\n\n response.setHeaders(mergedHeaders);\n\n if (operation.isRedirection(statusCode)) {\n response.redirect(statusCode, String(mergedHeaders[\"location\"]));\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCtxHandler = void 0;
|
|
4
|
+
const HandlerType_1 = require("../interfaces/HandlerType");
|
|
5
|
+
/**
|
|
6
|
+
* Create Ts.ED context handler
|
|
7
|
+
* @param fn
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
function useCtxHandler(fn) {
|
|
11
|
+
fn.type = HandlerType_1.HandlerType.CTX_FN;
|
|
12
|
+
return fn;
|
|
13
|
+
}
|
|
14
|
+
exports.useCtxHandler = useCtxHandler;
|
|
15
|
+
//# sourceMappingURL=useCtxHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCtxHandler.js","sourceRoot":"","sources":["../../../src/utils/useCtxHandler.ts"],"names":[],"mappings":";;;AACA,2DAAsD;AAItD;;;;GAIG;AACH,SAAgB,aAAa,CAAC,EAA6C;IACzE,EAAE,CAAC,IAAI,GAAG,yBAAW,CAAC,MAAM,CAAC;IAE7B,OAAO,EAAE,CAAC;AACZ,CAAC;AAJD,sCAIC","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\n\nexport type PlatformCtxHandler = ($ctx: PlatformContext) => any | Promise<any>;\n\n/**\n * Create Ts.ED context handler\n * @param fn\n * @ignore\n */\nexport function useCtxHandler(fn: PlatformCtxHandler & {type?: HandlerType}) {\n fn.type = HandlerType.CTX_FN;\n\n return fn;\n}\n"]}
|