@tsed/common 6.88.1 → 6.89.0
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/{PlatformModule.d.ts → cjs/PlatformModule.d.ts} +0 -0
- package/lib/cjs/PlatformModule.js +11 -0
- package/lib/cjs/PlatformModule.js.map +1 -0
- package/lib/{builder → cjs/builder}/PlatformBuilder.d.ts +0 -0
- package/lib/cjs/builder/PlatformBuilder.js +248 -0
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
- package/lib/{builder → cjs/builder}/PlatformControllerBuilder.d.ts +0 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js +85 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/{config → cjs/config}/index.d.ts +0 -0
- package/lib/cjs/config/index.js +7 -0
- package/lib/cjs/config/index.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/ConverterSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/EndpointDirectoriesSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +3 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformMulterSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformStaticsSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/index.d.ts +0 -0
- package/lib/cjs/config/interfaces/index.js +8 -0
- package/lib/cjs/config/interfaces/index.js.map +1 -0
- package/lib/{config → cjs/config}/services/PlatformConfiguration.d.ts +0 -0
- package/lib/cjs/config/services/PlatformConfiguration.js +195 -0
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/{constants → cjs/constants}/routerOptions.d.ts +0 -0
- package/lib/cjs/constants/routerOptions.js +5 -0
- package/lib/cjs/constants/routerOptions.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/httpServer.d.ts +0 -0
- package/lib/cjs/decorators/httpServer.js +31 -0
- package/lib/cjs/decorators/httpServer.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/httpsServer.d.ts +0 -0
- package/lib/cjs/decorators/httpsServer.js +31 -0
- package/lib/cjs/decorators/httpsServer.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +23 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/acceptMime.d.ts +0 -0
- package/lib/cjs/decorators/method/acceptMime.js +28 -0
- package/lib/cjs/decorators/method/acceptMime.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/endpointFn.d.ts +0 -0
- package/lib/cjs/decorators/method/endpointFn.js +15 -0
- package/lib/cjs/decorators/method/endpointFn.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/location.d.ts +0 -0
- package/lib/cjs/decorators/method/location.js +6 -0
- package/lib/cjs/decorators/method/location.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/redirect.d.ts +0 -0
- package/lib/cjs/decorators/method/redirect.js +6 -0
- package/lib/cjs/decorators/method/redirect.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/route.d.ts +0 -0
- package/lib/cjs/decorators/method/route.js +13 -0
- package/lib/cjs/decorators/method/route.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/view.d.ts +0 -0
- package/lib/cjs/decorators/method/view.js +34 -0
- package/lib/cjs/decorators/method/view.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/index.d.ts +0 -0
- package/lib/cjs/decorators/multer/index.js +7 -0
- package/lib/cjs/decorators/multer/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multerFileSize.d.ts +0 -0
- package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
- package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multerOptions.d.ts +0 -0
- package/lib/cjs/decorators/multer/multerOptions.js +52 -0
- package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multipartFile.d.ts +0 -0
- package/lib/cjs/decorators/multer/multipartFile.js +78 -0
- package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/endpointInfo.d.ts +0 -0
- package/lib/cjs/decorators/params/endpointInfo.js +21 -0
- package/lib/cjs/decorators/params/endpointInfo.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/error.d.ts +0 -0
- package/lib/cjs/decorators/params/error.js +20 -0
- package/lib/cjs/decorators/params/error.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/next.d.ts +0 -0
- package/lib/cjs/decorators/params/next.js +21 -0
- package/lib/cjs/decorators/params/next.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/request.d.ts +0 -0
- package/lib/cjs/decorators/params/request.js +39 -0
- package/lib/cjs/decorators/params/request.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/response.d.ts +0 -0
- package/lib/cjs/decorators/params/response.js +33 -0
- package/lib/cjs/decorators/params/response.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/responseData.d.ts +0 -0
- package/lib/cjs/decorators/params/responseData.js +21 -0
- package/lib/cjs/decorators/params/responseData.js.map +1 -0
- package/lib/{domain → cjs/domain}/AnyToPromiseWithCtx.d.ts +0 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +35 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/{domain → cjs/domain}/ControllerProvider.d.ts +0 -0
- package/lib/cjs/domain/ControllerProvider.js +51 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/{domain → cjs/domain}/EndpointMetadata.d.ts +0 -0
- package/lib/cjs/domain/EndpointMetadata.js +111 -0
- package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/HandlerMetadata.d.ts +0 -0
- package/lib/cjs/domain/HandlerMetadata.js +57 -0
- package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/PlatformContext.d.ts +0 -0
- package/lib/cjs/domain/PlatformContext.js +85 -0
- package/lib/cjs/domain/PlatformContext.js.map +1 -0
- package/lib/{domain → cjs/domain}/PlatformRouteDetails.d.ts +0 -0
- package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/{domain → cjs/domain}/PropertyMetadata.d.ts +0 -0
- package/lib/cjs/domain/PropertyMetadata.js +28 -0
- package/lib/cjs/domain/PropertyMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/index.d.ts +0 -0
- package/lib/cjs/domain/index.js +11 -0
- package/lib/cjs/domain/index.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +37 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterInit.d.ts +0 -0
- package/lib/cjs/interfaces/AfterInit.js +3 -0
- package/lib/cjs/interfaces/AfterInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterListen.d.ts +0 -0
- package/lib/cjs/interfaces/AfterListen.js +3 -0
- package/lib/cjs/interfaces/AfterListen.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeInit.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeInit.js +3 -0
- package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeListen.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeListen.js +3 -0
- package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/HandlerType.d.ts +0 -0
- package/lib/cjs/interfaces/HandlerType.js +17 -0
- package/lib/cjs/interfaces/HandlerType.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/IncomingEvent.d.ts +0 -0
- package/lib/cjs/interfaces/IncomingEvent.js +3 -0
- package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnReady.d.ts +0 -0
- package/lib/cjs/interfaces/OnReady.js +3 -0
- package/lib/cjs/interfaces/OnReady.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnRequest.d.ts +0 -0
- package/lib/cjs/interfaces/OnRequest.js +3 -0
- package/lib/cjs/interfaces/OnRequest.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnResponse.d.ts +0 -0
- package/lib/cjs/interfaces/OnResponse.js +3 -0
- package/lib/cjs/interfaces/OnResponse.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
- package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PathType.d.ts +0 -0
- package/lib/cjs/interfaces/PathType.js +3 -0
- package/lib/cjs/interfaces/PathType.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformRouteOptions.d.ts +0 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ResponseErrorObject.d.ts +0 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/Route.d.ts +0 -0
- package/lib/cjs/interfaces/Route.js +3 -0
- package/lib/cjs/interfaces/Route.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/index.d.ts +0 -0
- package/lib/cjs/interfaces/index.js +20 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/AcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/AcceptMimesMiddleware.js +27 -0
- package/lib/cjs/middlewares/AcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/GlobalAcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js +26 -0
- package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/PlatformMulterMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +55 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/{middlewares/data → cjs/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/bindEndpointMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/index.d.ts +0 -0
- package/lib/cjs/middlewares/index.js +9 -0
- package/lib/cjs/middlewares/index.js.map +1 -0
- package/lib/{services → cjs/services}/FakeRawDriver.d.ts +0 -0
- package/lib/cjs/services/FakeRawDriver.js +26 -0
- package/lib/cjs/services/FakeRawDriver.js.map +1 -0
- package/lib/{services → cjs/services}/Platform.d.ts +0 -0
- package/lib/cjs/services/Platform.js +107 -0
- package/lib/cjs/services/Platform.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformApplication.d.ts +0 -0
- package/lib/cjs/services/PlatformApplication.js +34 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformHandler.d.ts +0 -0
- package/lib/cjs/services/PlatformHandler.js +235 -0
- package/lib/cjs/services/PlatformHandler.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformMiddlewaresChain.d.ts +0 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js +34 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformRequest.d.ts +0 -0
- package/lib/cjs/services/PlatformRequest.js +138 -0
- package/lib/cjs/services/PlatformRequest.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformResponse.d.ts +0 -0
- package/lib/cjs/services/PlatformResponse.js +271 -0
- package/lib/cjs/services/PlatformResponse.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformRouter.d.ts +0 -0
- package/lib/cjs/services/PlatformRouter.js +126 -0
- package/lib/cjs/services/PlatformRouter.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformTest.d.ts +0 -0
- package/lib/cjs/services/PlatformTest.js +172 -0
- package/lib/cjs/services/PlatformTest.js.map +1 -0
- package/lib/{services → cjs/services}/index.d.ts +0 -0
- package/lib/cjs/services/index.js +12 -0
- package/lib/cjs/services/index.js.map +1 -0
- package/lib/{utils → cjs/utils}/createContext.d.ts +0 -0
- package/lib/cjs/utils/createContext.js +38 -0
- package/lib/cjs/utils/createContext.js.map +1 -0
- package/lib/{utils → cjs/utils}/createHandlerMetadata.d.ts +0 -0
- package/lib/cjs/utils/createHandlerMetadata.js +49 -0
- package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
- package/lib/{utils → cjs/utils}/createHttpServer.d.ts +0 -0
- package/lib/cjs/utils/createHttpServer.js +35 -0
- package/lib/cjs/utils/createHttpServer.js.map +1 -0
- package/lib/{utils → cjs/utils}/createHttpsServer.d.ts +0 -0
- package/lib/cjs/utils/createHttpsServer.js +36 -0
- package/lib/cjs/utils/createHttpsServer.js.map +1 -0
- package/lib/{utils → cjs/utils}/createInjector.d.ts +0 -0
- package/lib/cjs/utils/createInjector.js +42 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/{utils → cjs/utils}/getConfiguration.d.ts +0 -0
- package/lib/cjs/utils/getConfiguration.js +42 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/{utils → cjs/utils}/getStaticsOptions.d.ts +0 -0
- package/lib/cjs/utils/getStaticsOptions.js +21 -0
- package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
- package/lib/{utils → cjs/utils}/index.d.ts +0 -0
- package/lib/cjs/utils/index.js +12 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/{utils → cjs/utils}/listenServer.d.ts +0 -0
- package/lib/cjs/utils/listenServer.js +17 -0
- package/lib/cjs/utils/listenServer.js.map +1 -0
- package/lib/{utils → cjs/utils}/loadInjector.d.ts +0 -0
- package/lib/cjs/utils/loadInjector.js +14 -0
- package/lib/cjs/utils/loadInjector.js.map +1 -0
- package/lib/{utils → cjs/utils}/mapReturnedResponse.d.ts +0 -0
- package/lib/cjs/utils/mapReturnedResponse.js +15 -0
- package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
- package/lib/{utils → cjs/utils}/printRoutes.d.ts +0 -0
- package/lib/cjs/utils/printRoutes.js +36 -0
- package/lib/cjs/utils/printRoutes.js.map +1 -0
- package/lib/{utils → cjs/utils}/setResponseHeaders.d.ts +0 -0
- package/lib/cjs/utils/setResponseHeaders.js +35 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
- package/lib/{utils → cjs/utils}/useCtxHandler.d.ts +0 -0
- package/lib/cjs/utils/useCtxHandler.js +15 -0
- package/lib/cjs/utils/useCtxHandler.js.map +1 -0
- package/lib/esm/PlatformModule.js +7 -0
- package/lib/esm/PlatformModule.js.map +1 -0
- package/lib/esm/builder/PlatformBuilder.js +244 -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 +192 -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 +27 -0
- package/lib/esm/decorators/httpServer.js.map +1 -0
- package/lib/esm/decorators/httpsServer.js +27 -0
- package/lib/esm/decorators/httpsServer.js.map +1 -0
- package/lib/esm/decorators/index.js +20 -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/method/endpointFn.js +11 -0
- package/lib/esm/decorators/method/endpointFn.js.map +1 -0
- package/lib/esm/decorators/method/location.js +2 -0
- package/lib/esm/decorators/method/location.js.map +1 -0
- package/lib/esm/decorators/method/redirect.js +2 -0
- package/lib/esm/decorators/method/redirect.js.map +1 -0
- package/lib/esm/decorators/method/route.js +2 -0
- package/lib/esm/decorators/method/route.js.map +1 -0
- package/lib/esm/decorators/method/view.js +30 -0
- package/lib/esm/decorators/method/view.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/endpointInfo.js +17 -0
- package/lib/esm/decorators/params/endpointInfo.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/decorators/params/responseData.js +17 -0
- package/lib/esm/decorators/params/responseData.js.map +1 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js +31 -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 +108 -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 +81 -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/PropertyMetadata.js +25 -0
- package/lib/esm/domain/PropertyMetadata.js.map +1 -0
- package/lib/esm/domain/index.js +8 -0
- package/lib/esm/domain/index.js.map +1 -0
- package/lib/esm/index.js +31 -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/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 +17 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/middlewares/AcceptMimesMiddleware.js +24 -0
- package/lib/esm/middlewares/AcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.js +23 -0
- package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.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 +6 -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 +232 -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 +168 -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 +30 -0
- package/lib/esm/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/utils/createInjector.js +38 -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 +9 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/listenServer.js +13 -0
- package/lib/esm/utils/listenServer.js.map +1 -0
- package/lib/esm/utils/loadInjector.js +10 -0
- package/lib/esm/utils/loadInjector.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/types/PlatformModule.d.ts +6 -0
- package/lib/types/builder/PlatformBuilder.d.ts +116 -0
- package/lib/types/builder/PlatformControllerBuilder.d.ts +17 -0
- package/lib/types/config/index.d.ts +3 -0
- package/lib/types/config/interfaces/ConverterSettings.d.ts +6 -0
- package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +3 -0
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +44 -0
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +138 -0
- package/lib/types/config/interfaces/PlatformStaticsSettings.d.ts +17 -0
- package/lib/types/config/interfaces/index.d.ts +88 -0
- package/lib/types/config/services/PlatformConfiguration.d.ts +85 -0
- package/lib/types/constants/routerOptions.d.ts +1 -0
- package/lib/types/decorators/httpServer.d.ts +27 -0
- package/lib/types/decorators/httpsServer.d.ts +27 -0
- package/lib/types/decorators/index.d.ts +16 -0
- package/lib/types/decorators/method/acceptMime.d.ts +19 -0
- package/lib/types/decorators/method/endpointFn.d.ts +9 -0
- package/lib/types/decorators/method/location.d.ts +1 -0
- package/lib/types/decorators/method/redirect.d.ts +1 -0
- package/lib/types/decorators/method/route.d.ts +1 -0
- package/lib/types/decorators/method/view.d.ts +25 -0
- package/lib/types/decorators/multer/index.d.ts +3 -0
- package/lib/types/decorators/multer/multerFileSize.d.ts +27 -0
- package/lib/types/decorators/multer/multerOptions.d.ts +41 -0
- package/lib/types/decorators/multer/multipartFile.d.ts +47 -0
- package/lib/types/decorators/params/endpointInfo.d.ts +13 -0
- package/lib/types/decorators/params/error.d.ts +7 -0
- package/lib/types/decorators/params/next.d.ts +22 -0
- package/lib/types/decorators/params/request.d.ts +46 -0
- package/lib/types/decorators/params/response.d.ts +40 -0
- package/lib/types/decorators/params/responseData.d.ts +9 -0
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +18 -0
- package/lib/types/domain/ControllerProvider.d.ts +24 -0
- package/lib/types/domain/EndpointMetadata.d.ts +76 -0
- package/lib/types/domain/HandlerMetadata.d.ts +32 -0
- package/lib/types/domain/PlatformContext.d.ts +65 -0
- package/lib/types/domain/PlatformRouteDetails.d.ts +23 -0
- package/lib/types/domain/PropertyMetadata.d.ts +17 -0
- package/lib/types/domain/index.d.ts +7 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/interfaces/AfterInit.d.ts +3 -0
- package/lib/types/interfaces/AfterListen.d.ts +3 -0
- package/lib/types/interfaces/AfterRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/BeforeInit.d.ts +3 -0
- package/lib/types/interfaces/BeforeListen.d.ts +3 -0
- package/lib/types/interfaces/BeforeRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/HandlerType.d.ts +12 -0
- package/lib/types/interfaces/IncomingEvent.d.ts +6 -0
- package/lib/types/interfaces/OnReady.d.ts +3 -0
- package/lib/types/interfaces/OnRequest.d.ts +4 -0
- package/lib/types/interfaces/OnResponse.d.ts +4 -0
- package/lib/types/interfaces/OnRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/PathType.d.ts +1 -0
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +16 -0
- package/lib/types/interfaces/ResponseErrorObject.d.ts +8 -0
- package/lib/types/interfaces/Route.d.ts +10 -0
- package/lib/types/interfaces/index.d.ts +16 -0
- package/lib/types/middlewares/AcceptMimesMiddleware.d.ts +10 -0
- package/lib/types/middlewares/GlobalAcceptMimesMiddleware.d.ts +9 -0
- package/lib/types/middlewares/PlatformAcceptMimesMiddleware.d.ts +10 -0
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +19 -0
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +2 -0
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +5 -0
- package/lib/types/middlewares/index.d.ts +5 -0
- package/lib/types/services/FakeRawDriver.d.ts +15 -0
- package/lib/types/services/Platform.d.ts +37 -0
- package/lib/types/services/PlatformApplication.d.ts +21 -0
- package/lib/types/services/PlatformHandler.d.ts +80 -0
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -0
- package/lib/types/services/PlatformRequest.d.ts +112 -0
- package/lib/types/services/PlatformResponse.d.ts +161 -0
- package/lib/types/services/PlatformRouter.d.ts +48 -0
- package/lib/types/services/PlatformTest.d.ts +57 -0
- package/lib/types/services/index.d.ts +8 -0
- package/lib/types/utils/createContext.d.ts +9 -0
- package/lib/types/utils/createHandlerMetadata.d.ts +8 -0
- package/lib/types/utils/createHttpServer.d.ts +3 -0
- package/lib/types/utils/createHttpsServer.d.ts +3 -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/types/utils/index.d.ts +8 -0
- package/lib/types/utils/listenServer.d.ts +10 -0
- package/lib/types/utils/loadInjector.d.ts +6 -0
- package/lib/types/utils/mapReturnedResponse.d.ts +4 -0
- package/lib/types/utils/printRoutes.d.ts +2 -0
- package/lib/types/utils/setResponseHeaders.d.ts +5 -0
- package/lib/types/utils/useCtxHandler.d.ts +13 -0
- package/package.json +26 -22
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -3634
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3448
- package/lib/index.modern.js.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PlatformContext } from "../domain/PlatformContext";
|
|
2
|
+
import { PlatformRequest } from "../services/PlatformRequest";
|
|
3
|
+
import { PlatformResponse } from "../services/PlatformResponse";
|
|
4
|
+
const uuidv4 = require("uuid").v4;
|
|
5
|
+
const defaultReqIdBuilder = (req) => req.get("x-request-id") || uuidv4().replace(/-/gi, "");
|
|
6
|
+
/**
|
|
7
|
+
* Create the TsED context to wrap request, response, injector, etc...
|
|
8
|
+
* @param injector
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export function createContext(injector) {
|
|
12
|
+
var _a, _b;
|
|
13
|
+
const ResponseKlass = (_a = injector.getProvider(PlatformResponse)) === null || _a === void 0 ? void 0 : _a.useClass;
|
|
14
|
+
const RequestKlass = (_b = injector.getProvider(PlatformRequest)) === null || _b === void 0 ? void 0 : _b.useClass;
|
|
15
|
+
const { reqIdBuilder = defaultReqIdBuilder, ...loggerOptions } = injector.settings.logger || {};
|
|
16
|
+
return async (event) => {
|
|
17
|
+
const ctx = new PlatformContext({
|
|
18
|
+
event,
|
|
19
|
+
id: reqIdBuilder(event.request),
|
|
20
|
+
logger: injector.logger,
|
|
21
|
+
...loggerOptions,
|
|
22
|
+
injector,
|
|
23
|
+
ResponseKlass,
|
|
24
|
+
RequestKlass
|
|
25
|
+
});
|
|
26
|
+
ctx.response.onEnd(async () => {
|
|
27
|
+
await ctx.emit("$onResponse", ctx);
|
|
28
|
+
await ctx.destroy();
|
|
29
|
+
});
|
|
30
|
+
await ctx.emit("$onRequest", ctx);
|
|
31
|
+
return ctx;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=createContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createContext.js","sourceRoot":"","sources":["../../../src/utils/createContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAC,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;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,MAAM,UAAU,aAAa,CAAC,QAAyB;;IACrD,MAAM,aAAa,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,gBAAgB,CAAC,0CAAE,QAAQ,CAAC;IACvE,MAAM,YAAY,GAAG,MAAA,QAAQ,CAAC,WAAW,CAAC,eAAe,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,eAAe,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","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,45 @@
|
|
|
1
|
+
import { EndpointMetadata } from "../domain/EndpointMetadata";
|
|
2
|
+
import { HandlerMetadata } from "../domain/HandlerMetadata";
|
|
3
|
+
import { HandlerType } from "../interfaces/HandlerType";
|
|
4
|
+
function isMetadata(input) {
|
|
5
|
+
return input instanceof HandlerMetadata;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export function createHandlerMetadata(injector, obj, routeOptions = {}) {
|
|
11
|
+
if (isMetadata(obj)) {
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
let options;
|
|
15
|
+
if (obj instanceof EndpointMetadata) {
|
|
16
|
+
const provider = injector.getProvider(routeOptions.token);
|
|
17
|
+
options = {
|
|
18
|
+
token: provider.token,
|
|
19
|
+
target: provider.useClass,
|
|
20
|
+
scope: provider.scope,
|
|
21
|
+
type: HandlerType.ENDPOINT,
|
|
22
|
+
propertyKey: obj.propertyKey
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
const provider = injector.getProvider(obj);
|
|
27
|
+
if (provider) {
|
|
28
|
+
options = {
|
|
29
|
+
token: provider.token,
|
|
30
|
+
target: provider.useClass,
|
|
31
|
+
scope: provider.scope,
|
|
32
|
+
type: HandlerType.MIDDLEWARE,
|
|
33
|
+
propertyKey: "use"
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
options = {
|
|
38
|
+
target: obj
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
options.routeOptions = routeOptions;
|
|
43
|
+
return new HandlerMetadata(options);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=createHandlerMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHandlerMetadata.js","sourceRoot":"","sources":["../../../src/utils/createHandlerMetadata.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAC,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAC,eAAe,EAAyB,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAGtD,SAAS,UAAU,CAAC,KAAU;IAC5B,OAAO,KAAK,YAAY,eAAe,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,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,gBAAgB,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,WAAW,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,WAAW,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,eAAe,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC","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,29 @@
|
|
|
1
|
+
import { ProviderScope, registerProvider } from "@tsed/di";
|
|
2
|
+
import Http from "http";
|
|
3
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
4
|
+
import { HttpServer } from "../decorators/httpServer";
|
|
5
|
+
import { listenServer } from "./listenServer";
|
|
6
|
+
export function createHttpServer(injector) {
|
|
7
|
+
injector.invoke(HttpServer);
|
|
8
|
+
}
|
|
9
|
+
registerProvider({
|
|
10
|
+
provide: HttpServer,
|
|
11
|
+
deps: [PlatformApplication],
|
|
12
|
+
scope: ProviderScope.SINGLETON,
|
|
13
|
+
global: true,
|
|
14
|
+
useFactory(platformApplication) {
|
|
15
|
+
return Http.createServer(platformApplication.callback());
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export async function listenHttpServer(injector) {
|
|
19
|
+
const { settings } = injector;
|
|
20
|
+
const server = injector.get(HttpServer);
|
|
21
|
+
if (settings.httpPort !== false && server) {
|
|
22
|
+
const { address, port } = settings.getHttpPort();
|
|
23
|
+
injector.logger.debug(`Start server on http://${address}:${port}`);
|
|
24
|
+
const options = await listenServer(server, { address, port });
|
|
25
|
+
settings.setHttpPort(options);
|
|
26
|
+
injector.logger.info(`Listen server on http://${options.address}:${options.port}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=createHttpServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC1E,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,gBAAgB,CAAC,QAAyB;IACxD,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC;AAED,gBAAgB,CAAC;IACf,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,CAAC,mBAAmB,CAAC;IAC3B,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,MAAM,EAAE,IAAI;IACZ,UAAU,CAAC,mBAAwC;QACjD,OAAO,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3D,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,QAAyB;IAC9D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAa,UAAU,CAAC,CAAC;IAEpD,IAAI,QAAQ,CAAC,QAAQ,KAAK,KAAK,IAAI,MAAM,EAAE;QACzC,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;QAC/C,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,0BAA0B,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;QAEnE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAE9B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACpF;AACH,CAAC","sourcesContent":["import {InjectorService, ProviderScope, registerProvider} from \"@tsed/di\";\nimport Http from \"http\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {HttpServer} from \"../decorators/httpServer\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpServer(injector: InjectorService): void {\n injector.invoke(HttpServer);\n}\n\nregisterProvider({\n provide: HttpServer,\n deps: [PlatformApplication],\n scope: ProviderScope.SINGLETON,\n global: true,\n useFactory(platformApplication: PlatformApplication) {\n return Http.createServer(platformApplication.callback());\n }\n});\n\nexport async function listenHttpServer(injector: InjectorService) {\n const {settings} = injector;\n const server = injector.get<HttpServer>(HttpServer);\n\n if (settings.httpPort !== false && server) {\n const {address, port} = settings.getHttpPort();\n injector.logger.debug(`Start server on http://${address}:${port}`);\n\n const options = await listenServer(server, {address, port});\n settings.setHttpPort(options);\n\n injector.logger.info(`Listen server on http://${options.address}:${options.port}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Configuration, ProviderScope, registerProvider } from "@tsed/di";
|
|
2
|
+
import Https from "https";
|
|
3
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
4
|
+
import { HttpsServer } from "../decorators/httpsServer";
|
|
5
|
+
import { listenServer } from "./listenServer";
|
|
6
|
+
export function createHttpsServer(injector) {
|
|
7
|
+
injector.invoke(HttpsServer);
|
|
8
|
+
}
|
|
9
|
+
registerProvider({
|
|
10
|
+
provide: HttpsServer,
|
|
11
|
+
deps: [PlatformApplication, Configuration],
|
|
12
|
+
scope: ProviderScope.SINGLETON,
|
|
13
|
+
global: true,
|
|
14
|
+
useFactory(platformApplication, settings) {
|
|
15
|
+
const options = settings.httpsOptions;
|
|
16
|
+
return Https.createServer(options, platformApplication.callback());
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
export async function listenHttpsServer(injector) {
|
|
20
|
+
const { settings } = injector;
|
|
21
|
+
const server = injector.get(HttpsServer);
|
|
22
|
+
if (settings.httpsPort !== false && server) {
|
|
23
|
+
const { address, port } = settings.getHttpsPort();
|
|
24
|
+
injector.logger.debug(`Start server on https://${address}:${port}`);
|
|
25
|
+
const options = await listenServer(server, { address, port });
|
|
26
|
+
settings.setHttpsPort(options);
|
|
27
|
+
injector.logger.info(`Listen server on https://${options.address}:${options.port}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=createHttpsServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHttpsServer.js","sourceRoot":"","sources":["../../../src/utils/createHttpsServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAmB,aAAa,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACzF,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAE5C,MAAM,UAAU,iBAAiB,CAAC,QAAyB;IACzD,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC;AAED,gBAAgB,CAAC;IACf,OAAO,EAAE,WAAW;IACpB,IAAI,EAAE,CAAC,mBAAmB,EAAE,aAAa,CAAC;IAC1C,KAAK,EAAE,aAAa,CAAC,SAAS;IAC9B,MAAM,EAAE,IAAI;IACZ,UAAU,CAAC,mBAAwC,EAAE,QAAuB;QAC1E,MAAM,OAAO,GAAG,QAAQ,CAAC,YAAa,CAAC;QAEvC,OAAO,KAAK,CAAC,YAAY,CAAC,OAAO,EAAE,mBAAmB,CAAC,QAAQ,EAAE,CAAC,CAAC;IACrE,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,QAAyB;IAC/D,MAAM,EAAC,QAAQ,EAAC,GAAG,QAAQ,CAAC;IAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAc,WAAW,CAAC,CAAC;IAEtD,IAAI,QAAQ,CAAC,SAAS,KAAK,KAAK,IAAI,MAAM,EAAE;QAC1C,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAC;QAChD,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,2BAA2B,OAAO,IAAI,IAAI,EAAE,CAAC,CAAC;QAEpE,MAAM,OAAO,GAAG,MAAM,YAAY,CAAC,MAAM,EAAE,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAC;QAC5D,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAE/B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;KACrF;AACH,CAAC","sourcesContent":["import {Configuration, InjectorService, ProviderScope, registerProvider} from \"@tsed/di\";\nimport Https from \"https\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {HttpsServer} from \"../decorators/httpsServer\";\nimport {listenServer} from \"./listenServer\";\n\nexport function createHttpsServer(injector: InjectorService): void {\n injector.invoke(HttpsServer);\n}\n\nregisterProvider({\n provide: HttpsServer,\n deps: [PlatformApplication, Configuration],\n scope: ProviderScope.SINGLETON,\n global: true,\n useFactory(platformApplication: PlatformApplication, settings: Configuration) {\n const options = settings.httpsOptions!;\n\n return Https.createServer(options, platformApplication.callback());\n }\n});\n\nexport async function listenHttpsServer(injector: InjectorService) {\n const {settings} = injector;\n const server = injector.get<HttpsServer>(HttpsServer);\n\n if (settings.httpsPort !== false && server) {\n const {address, port} = settings.getHttpsPort();\n injector.logger.debug(`Start server on https://${address}:${port}`);\n\n const options = await listenServer(server, {address, port});\n settings.setHttpsPort(options);\n\n injector.logger.info(`Listen server on https://${options.address}:${options.port}`);\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { InjectorService, setLoggerLevel } from "@tsed/di";
|
|
2
|
+
import { $log } from "@tsed/logger";
|
|
3
|
+
import { toMap } from "@tsed/core";
|
|
4
|
+
import { PlatformConfiguration } from "../config/services/PlatformConfiguration";
|
|
5
|
+
import { PlatformHandler } from "../services/PlatformHandler";
|
|
6
|
+
import { PlatformResponse } from "../services/PlatformResponse";
|
|
7
|
+
import { PlatformRouter } from "../services/PlatformRouter";
|
|
8
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
9
|
+
import { Platform } from "../services/Platform";
|
|
10
|
+
import { PlatformRequest } from "../services/PlatformRequest";
|
|
11
|
+
import { createHttpsServer } from "./createHttpsServer";
|
|
12
|
+
import { createHttpServer } from "./createHttpServer";
|
|
13
|
+
$log.name = "TSED";
|
|
14
|
+
const DEFAULT_PROVIDERS = [
|
|
15
|
+
{ provide: PlatformHandler },
|
|
16
|
+
{ provide: PlatformResponse },
|
|
17
|
+
{ provide: PlatformRequest },
|
|
18
|
+
{ provide: PlatformRouter },
|
|
19
|
+
{ provide: PlatformApplication },
|
|
20
|
+
{ provide: Platform }
|
|
21
|
+
];
|
|
22
|
+
export function createInjector({ providers = [], settings = {} }) {
|
|
23
|
+
const injector = new InjectorService();
|
|
24
|
+
injector.addProvider(PlatformConfiguration);
|
|
25
|
+
injector.settings = injector.invoke(PlatformConfiguration);
|
|
26
|
+
injector.logger = $log;
|
|
27
|
+
injector.settings.set(settings);
|
|
28
|
+
setLoggerLevel(injector);
|
|
29
|
+
providers = [...DEFAULT_PROVIDERS, ...providers];
|
|
30
|
+
toMap(providers, "provide").forEach((provider, token) => {
|
|
31
|
+
injector.addProvider(token, provider);
|
|
32
|
+
});
|
|
33
|
+
injector.invoke(PlatformApplication);
|
|
34
|
+
createHttpsServer(injector);
|
|
35
|
+
createHttpServer(injector);
|
|
36
|
+
return injector;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=createInjector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../src/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAa,cAAc,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EAAC,KAAK,EAAO,MAAM,YAAY,CAAC;AACvC,OAAO,EAAC,qBAAqB,EAAC,MAAM,0CAA0C,CAAC;AAC/E,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,cAAc,EAAC,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,QAAQ,EAAC,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AAEpD,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,iBAAiB,GAAG;IACxB,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,gBAAgB,EAAC;IAC3B,EAAC,OAAO,EAAE,eAAe,EAAC;IAC1B,EAAC,OAAO,EAAE,cAAc,EAAC;IACzB,EAAC,OAAO,EAAE,mBAAmB,EAAC;IAC9B,EAAC,OAAO,EAAE,QAAQ,EAAC;CACpB,CAAC;AAOF,MAAM,UAAU,cAAc,CAAC,EAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,GAAG,EAAE,EAAwB;IACnF,MAAM,QAAQ,GAAG,IAAI,eAAe,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAE5C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IAC3D,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEhC,cAAc,CAAC,QAAQ,CAAC,CAAC;IAEzB,SAAS,GAAG,CAAC,GAAG,iBAAiB,EAAE,GAAG,SAAS,CAAC,CAAC;IAEjD,KAAK,CAAiB,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,mBAAmB,CAAC,CAAC;IACrC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAC5B,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAE3B,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import {InjectorService, IProvider, 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 {createHttpsServer} from \"./createHttpsServer\";\nimport {createHttpServer} from \"./createHttpServer\";\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 createHttpsServer(injector);\n createHttpServer(injector);\n\n return injector;\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { deepMerge, Env, Store } from "@tsed/core";
|
|
2
|
+
import { ProviderScope, ProviderType } from "@tsed/di";
|
|
3
|
+
export function getConfiguration(configuration = {}, module = null) {
|
|
4
|
+
const store = module ? Store.from(module).get("configuration") || {} : {};
|
|
5
|
+
const env = configuration.env || store.mount || process.env.NODE_ENV || Env.DEV;
|
|
6
|
+
const config = {
|
|
7
|
+
exclude: ["**/*.spec.ts", "**/*.spec.js"],
|
|
8
|
+
componentsScan: ["${rootDir}/mvc/**/*.ts", "${rootDir}/services/**/*.ts", "${rootDir}/middlewares/**/*.ts"],
|
|
9
|
+
env,
|
|
10
|
+
httpPort: 8080,
|
|
11
|
+
httpsPort: false,
|
|
12
|
+
...store,
|
|
13
|
+
...configuration,
|
|
14
|
+
scopes: {
|
|
15
|
+
[ProviderType.CONTROLLER]: ProviderScope.SINGLETON,
|
|
16
|
+
...store.scopes,
|
|
17
|
+
...configuration.scopes
|
|
18
|
+
},
|
|
19
|
+
mount: store.mount || configuration.mount
|
|
20
|
+
? deepMerge(store.mount || {}, configuration.mount || {})
|
|
21
|
+
: {
|
|
22
|
+
"/rest": "${rootDir}/controllers/**/*.ts"
|
|
23
|
+
},
|
|
24
|
+
logger: {
|
|
25
|
+
debug: false,
|
|
26
|
+
level: env === Env.TEST ? "off" : "info",
|
|
27
|
+
logRequest: true,
|
|
28
|
+
...store.logger,
|
|
29
|
+
...configuration.logger,
|
|
30
|
+
jsonIndentation: process.env.NODE_ENV === Env.PROD ? 0 : 2
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
if (!configuration.disableComponentsScan && store.componentsScan && configuration.componentsScan) {
|
|
34
|
+
config.componentsScan = [...store.componentsScan, ...configuration.componentsScan];
|
|
35
|
+
}
|
|
36
|
+
return config;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=getConfiguration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getConfiguration.js","sourceRoot":"","sources":["../../../src/utils/getConfiguration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,GAAG,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACvD,OAAO,EAAC,aAAa,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AAErD,MAAM,UAAU,gBAAgB,CAAC,gBAAqB,EAAE,EAAE,SAA2B,IAAI;IACvF,MAAM,KAAK,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,GAAG,GAAG,aAAa,CAAC,GAAG,IAAI,KAAK,CAAC,KAAK,IAAK,OAAO,CAAC,GAAG,CAAC,QAAgB,IAAI,GAAG,CAAC,GAAG,CAAC;IAEzF,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,YAAY,CAAC,UAAU,CAAC,EAAE,aAAa,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,SAAS,CAAC,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,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;YACxC,UAAU,EAAE,IAAI;YAChB,GAAG,KAAK,CAAC,MAAM;YACf,GAAG,aAAa,CAAC,MAAM;YACvB,eAAe,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3D;KACF,CAAC;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","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.mount || (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,17 @@
|
|
|
1
|
+
import { getValue } from "@tsed/core";
|
|
2
|
+
function mapOptions(options) {
|
|
3
|
+
const opts = typeof options === "string" ? { root: options } : options;
|
|
4
|
+
return {
|
|
5
|
+
...opts,
|
|
6
|
+
hook: getValue(opts, "hook", "$afterRoutesInit")
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function getStaticsOptions(statics) {
|
|
10
|
+
return Object.entries(statics || {}).reduce((statics, [path, items]) => {
|
|
11
|
+
[].concat(items).forEach((options) => {
|
|
12
|
+
statics.push({ path, options: mapOptions(options) });
|
|
13
|
+
});
|
|
14
|
+
return statics;
|
|
15
|
+
}, []);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getStaticsOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getStaticsOptions.js","sourceRoot":"","sources":["../../../src/utils/getStaticsOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;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,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,kBAAkB,CAAC;KACjD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,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","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,9 @@
|
|
|
1
|
+
export * from "./createInjector";
|
|
2
|
+
export * from "./createHttpServer";
|
|
3
|
+
export * from "./createHttpsServer";
|
|
4
|
+
export * from "./loadInjector";
|
|
5
|
+
export * from "./printRoutes";
|
|
6
|
+
export * from "./listenServer";
|
|
7
|
+
export * from "./createContext";
|
|
8
|
+
export * from "./useCtxHandler";
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC","sourcesContent":["export * from \"./createInjector\";\nexport * from \"./createHttpServer\";\nexport * from \"./createHttpsServer\";\nexport * from \"./loadInjector\";\nexport * from \"./printRoutes\";\nexport * from \"./listenServer\";\nexport * from \"./createContext\";\nexport * from \"./useCtxHandler\";\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export function listenServer(http, settings) {
|
|
2
|
+
const { address, port } = settings;
|
|
3
|
+
const promise = new Promise((resolve, reject) => {
|
|
4
|
+
http.on("listening", resolve);
|
|
5
|
+
http.on("error", reject);
|
|
6
|
+
}).then(() => {
|
|
7
|
+
const port = http.address().port;
|
|
8
|
+
return { address: settings.address, port };
|
|
9
|
+
});
|
|
10
|
+
http.listen(port, address);
|
|
11
|
+
return promise;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=listenServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listenServer.js","sourceRoot":"","sources":["../../../src/utils/listenServer.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,YAAY,CAC1B,IAAgC,EAChC,QAAkD;IAElD,MAAM,EAAC,OAAO,EAAE,IAAI,EAAC,GAAG,QAAQ,CAAC;IAEjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC9C,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QAC9B,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC3B,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE;QACX,MAAM,IAAI,GAAI,IAAI,CAAC,OAAO,EAAU,CAAC,IAAI,CAAC;QAE1C,OAAO,EAAC,OAAO,EAAE,QAAQ,CAAC,OAAiB,EAAE,IAAI,EAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAc,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import Http from \"http\";\nimport Https from \"https\";\n\nexport function listenServer(\n http: Http.Server | Https.Server,\n settings: {address: string | number; port: number}\n): Promise<{address: string; port: number}> {\n const {address, port} = settings;\n\n const promise = new Promise((resolve, reject) => {\n http.on(\"listening\", resolve);\n http.on(\"error\", reject);\n }).then(() => {\n const port = (http.address() as any).port;\n\n return {address: settings.address as string, port};\n });\n\n http.listen(port, address as any);\n\n return promise;\n}\n"]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { createContainer } from "@tsed/di";
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
* @deprecated User injector.load(container, module) instead
|
|
5
|
+
*/
|
|
6
|
+
export async function loadInjector(injector, container = createContainer()) {
|
|
7
|
+
injector.bootstrap(container);
|
|
8
|
+
return injector.load(container);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=loadInjector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadInjector.js","sourceRoot":"","sources":["../../../src/utils/loadInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,eAAe,EAAmC,MAAM,UAAU,CAAC;AAEtF;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,QAAyB,EAAE,YAAuB,eAAe,EAAE;IACpG,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC","sourcesContent":["import {Container, createContainer, InjectorService, LocalsContainer} from \"@tsed/di\";\n\n/**\n * @ignore\n * @deprecated User injector.load(container, module) instead\n */\nexport async function loadInjector(injector: InjectorService, container: Container = createContainer()): Promise<LocalsContainer<any>> {\n injector.bootstrap(container);\n return injector.load(container);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
*/
|
|
4
|
+
export function mapReturnedResponse({ use, collection, ...options }) {
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
type: options.type || use,
|
|
8
|
+
collectionType: options.collectionType || collection
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=mapReturnedResponse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapReturnedResponse.js","sourceRoot":"","sources":["../../../src/utils/mapReturnedResponse.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,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","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,32 @@
|
|
|
1
|
+
import { $log, colorize } from "@tsed/logger";
|
|
2
|
+
export function printRoutes(routes) {
|
|
3
|
+
const mapColor = {
|
|
4
|
+
GET: "green",
|
|
5
|
+
POST: "yellow",
|
|
6
|
+
PUT: "blue",
|
|
7
|
+
DELETE: "red",
|
|
8
|
+
PATCH: "magenta",
|
|
9
|
+
ALL: "cyan"
|
|
10
|
+
};
|
|
11
|
+
const list = routes.map((route) => {
|
|
12
|
+
const obj = route.toJSON();
|
|
13
|
+
const method = obj.method.toUpperCase();
|
|
14
|
+
obj.method = {
|
|
15
|
+
length: method.length,
|
|
16
|
+
toString: () => {
|
|
17
|
+
return colorize(method, mapColor[method]);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
return obj;
|
|
21
|
+
});
|
|
22
|
+
const str = $log.drawTable(list, {
|
|
23
|
+
padding: 1,
|
|
24
|
+
header: {
|
|
25
|
+
method: "Method",
|
|
26
|
+
url: "Endpoint",
|
|
27
|
+
name: "Class method"
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return "\n" + str.trim();
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=printRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"printRoutes.js","sourceRoot":"","sources":["../../../src/utils/printRoutes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAG5C,MAAM,UAAU,WAAW,CAAC,MAA8B;IACxD,MAAM,QAAQ,GAA4B;QACxC,GAAG,EAAE,OAAO;QACZ,IAAI,EAAE,QAAQ;QACd,GAAG,EAAE,MAAM;QACX,MAAM,EAAE,KAAK;QACb,KAAK,EAAE,SAAS;QAChB,GAAG,EAAE,MAAM;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,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5C,CAAC;SACK,CAAC;QAET,OAAO,GAAG,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,MAAM,GAAG,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;QAC/B,OAAO,EAAE,CAAC;QACV,MAAM,EAAE;YACN,MAAM,EAAE,QAAQ;YAChB,GAAG,EAAE,UAAU;YACf,IAAI,EAAE,cAAc;SACrB;KACF,CAAC,CAAC;IAEH,OAAO,IAAI,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import {$log, colorize} from \"@tsed/logger\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\n\nexport function printRoutes(routes: PlatformRouteDetails[]) {\n const mapColor: {[key: string]: string} = {\n GET: \"green\",\n POST: \"yellow\",\n PUT: \"blue\",\n DELETE: \"red\",\n PATCH: \"magenta\",\n ALL: \"cyan\"\n };\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,31 @@
|
|
|
1
|
+
function mergeHeaders(specHeaders, headers) {
|
|
2
|
+
return Object.entries(specHeaders).reduce((headers, [key, item]) => {
|
|
3
|
+
key = key.toLowerCase();
|
|
4
|
+
return {
|
|
5
|
+
...headers,
|
|
6
|
+
[key]: headers[key] === undefined ? String(item.example) : headers[key]
|
|
7
|
+
};
|
|
8
|
+
}, headers);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @ignore
|
|
12
|
+
*/
|
|
13
|
+
export function setResponseHeaders(ctx) {
|
|
14
|
+
const { response, endpoint } = ctx;
|
|
15
|
+
const { operation } = endpoint;
|
|
16
|
+
if (response.isDone()) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (!response.hasStatus()) {
|
|
20
|
+
// apply status only if the isn't already modified
|
|
21
|
+
response.status(operation.getStatus());
|
|
22
|
+
}
|
|
23
|
+
const statusCode = response.statusCode;
|
|
24
|
+
const headers = operation.getHeadersOf(response.statusCode);
|
|
25
|
+
const mergedHeaders = mergeHeaders(headers, response.getHeaders());
|
|
26
|
+
response.setHeaders(mergedHeaders);
|
|
27
|
+
if (operation.isRedirection(statusCode)) {
|
|
28
|
+
response.redirect(statusCode, String(mergedHeaders["location"]));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# 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,MAAM,UAAU,kBAAkB,CAAC,GAAoB;IACrD,MAAM,EAAC,QAAQ,EAAE,QAAQ,EAAC,GAAG,GAAG,CAAC;IACjC,MAAM,EAAC,SAAS,EAAC,GAAG,QAAQ,CAAC;IAE7B,IAAI,QAAQ,CAAC,MAAM,EAAE,EAAE;QACrB,OAAO;KACR;IAED,IAAI,CAAC,QAAQ,CAAC,SAAS,EAAE,EAAE;QACzB,kDAAkD;QAClD,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;KACxC;IAED,MAAM,UAAU,GAAG,QAAQ,CAAC,UAAU,CAAC;IACvC,MAAM,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC,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","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,11 @@
|
|
|
1
|
+
import { HandlerType } from "../interfaces/HandlerType";
|
|
2
|
+
/**
|
|
3
|
+
* Create Ts.ED context handler
|
|
4
|
+
* @param fn
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export function useCtxHandler(fn) {
|
|
8
|
+
fn.type = HandlerType.CTX_FN;
|
|
9
|
+
return fn;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=useCtxHandler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCtxHandler.js","sourceRoot":"","sources":["../../../src/utils/useCtxHandler.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAItD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,EAA6C;IACzE,EAAE,CAAC,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC;IAE7B,OAAO,EAAE,CAAC;AACZ,CAAC","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"]}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Type } from "@tsed/core";
|
|
3
|
+
import { InjectorService, IProvider } from "@tsed/di";
|
|
4
|
+
import { Platform } from "../services/Platform";
|
|
5
|
+
import { PlatformApplication } from "../services/PlatformApplication";
|
|
6
|
+
import { IncomingMessage, ServerResponse } from "http";
|
|
7
|
+
/**
|
|
8
|
+
* @ignore
|
|
9
|
+
*/
|
|
10
|
+
export interface PlatformType<T = any> extends Type<T> {
|
|
11
|
+
providers: IProvider[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
export interface PlatformBootstrap {
|
|
17
|
+
create(module: Type<any>, settings?: Partial<TsED.Configuration>): PlatformBuilder;
|
|
18
|
+
bootstrap(module: Type<any>, settings?: Partial<TsED.Configuration>): Promise<PlatformBuilder>;
|
|
19
|
+
}
|
|
20
|
+
export interface PlatformBuilderOptions {
|
|
21
|
+
name: string;
|
|
22
|
+
providers: IProvider[];
|
|
23
|
+
settings: any;
|
|
24
|
+
module: Type<any>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* @platform
|
|
28
|
+
*/
|
|
29
|
+
export declare abstract class PlatformBuilder<App = TsED.Application, Router = TsED.Router> {
|
|
30
|
+
#private;
|
|
31
|
+
static currentPlatform: Type<PlatformBuilder<any, any>> & PlatformBootstrap;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
protected startedAt: Date;
|
|
34
|
+
protected current: Date;
|
|
35
|
+
constructor({ name, providers, settings, module }: PlatformBuilderOptions);
|
|
36
|
+
get injector(): InjectorService;
|
|
37
|
+
get rootModule(): any;
|
|
38
|
+
get app(): PlatformApplication<App, Router>;
|
|
39
|
+
get platform(): Platform;
|
|
40
|
+
/**
|
|
41
|
+
* Return the settings configured by the decorator @@Configuration@@.
|
|
42
|
+
*
|
|
43
|
+
* ```typescript
|
|
44
|
+
* @Configuration({
|
|
45
|
+
* rootDir: Path.resolve(__dirname),
|
|
46
|
+
* port: 8000,
|
|
47
|
+
* httpsPort: 8080,
|
|
48
|
+
* mount: {
|
|
49
|
+
* "/rest": "${rootDir}/controllers/**\/*.js"
|
|
50
|
+
* }
|
|
51
|
+
* })
|
|
52
|
+
* export class Server {
|
|
53
|
+
* $onInit(){
|
|
54
|
+
* console.log(this.settings); // {rootDir, port, httpsPort,...}
|
|
55
|
+
* }
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @returns {PlatformConfiguration}
|
|
60
|
+
*/
|
|
61
|
+
get settings(): TsED.Configuration & import("@tsed/di").DIConfiguration;
|
|
62
|
+
get logger(): import("@tsed/di").DILogger;
|
|
63
|
+
get disableBootstrapLog(): boolean | undefined;
|
|
64
|
+
static build<T extends PlatformBuilder<any, any>>(platformBuildClass: PlatformType<T>, module: Type<any>, settings?: Partial<TsED.Configuration>): T;
|
|
65
|
+
callback(): (req: IncomingMessage, res: ServerResponse) => void;
|
|
66
|
+
callback(req: IncomingMessage, res: ServerResponse): void;
|
|
67
|
+
log(...data: any[]): any;
|
|
68
|
+
/**
|
|
69
|
+
* Add classes to the components list
|
|
70
|
+
* @param classes
|
|
71
|
+
*/
|
|
72
|
+
addComponents(classes: any | any[]): this;
|
|
73
|
+
/**
|
|
74
|
+
* Add classes decorated by @@Controller@@ to components container.
|
|
75
|
+
*
|
|
76
|
+
* ### Example
|
|
77
|
+
*
|
|
78
|
+
* ```typescript
|
|
79
|
+
* @Controller('/ctrl')
|
|
80
|
+
* class MyController{
|
|
81
|
+
* }
|
|
82
|
+
*
|
|
83
|
+
* platform.addControllers('/rest', [MyController])
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* ::: tip
|
|
87
|
+
* If the MyController class isn't decorated, the class will be ignored.
|
|
88
|
+
* :::
|
|
89
|
+
*
|
|
90
|
+
* @param {string} endpoint
|
|
91
|
+
* @param {any[]} controllers
|
|
92
|
+
*/
|
|
93
|
+
addControllers(endpoint: string, controllers: any | string | (any | string)[]): void;
|
|
94
|
+
runLifecycle(): Promise<this>;
|
|
95
|
+
loadInjector(): Promise<void>;
|
|
96
|
+
listen(): Promise<void>;
|
|
97
|
+
stop(): Promise<void>;
|
|
98
|
+
ready(): Promise<void>;
|
|
99
|
+
callHook(hook: string, ...args: any[]): Promise<void>;
|
|
100
|
+
loadStatics(hook: string): Promise<void>;
|
|
101
|
+
useProvider(token: Type<any>, settings?: Partial<IProvider>): this;
|
|
102
|
+
bootstrap(): Promise<this>;
|
|
103
|
+
protected diff(): string;
|
|
104
|
+
protected importProviders(): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Load middlewares from configuration for the given hook
|
|
107
|
+
* @param hook
|
|
108
|
+
* @protected
|
|
109
|
+
*/
|
|
110
|
+
protected loadMiddlewaresFor(hook: string): void;
|
|
111
|
+
protected useRouter(): this;
|
|
112
|
+
protected useContext(): this;
|
|
113
|
+
protected listenServers(): Promise<void>;
|
|
114
|
+
protected logRoutes(): Promise<void>;
|
|
115
|
+
protected loadRoutes(): Promise<void>;
|
|
116
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { InjectorService } from "@tsed/di";
|
|
2
|
+
import { ControllerProvider } from "../domain/ControllerProvider";
|
|
3
|
+
import { PlatformRouter } from "../services/PlatformRouter";
|
|
4
|
+
/**
|
|
5
|
+
* @ignore
|
|
6
|
+
*/
|
|
7
|
+
export declare function getRouter(injector: InjectorService, provider: ControllerProvider): any;
|
|
8
|
+
/**
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export declare function createRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter;
|
|
12
|
+
/**
|
|
13
|
+
* @ignore
|
|
14
|
+
* @param injector
|
|
15
|
+
* @param provider
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildRouter(injector: InjectorService, provider: ControllerProvider): PlatformRouter<TsED.Router>;
|