@tsed/common 7.0.0-alpha.2 → 7.0.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/builder/PlatformBuilder.js +281 -0
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js +82 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/cjs/config/services/PlatformConfiguration.js +187 -0
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/cjs/constants/routerOptions.js +5 -0
- package/lib/cjs/constants/routerOptions.js.map +1 -0
- package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
- package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/cjs/decorators/multer/multerOptions.js +52 -0
- package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
- package/lib/cjs/decorators/multer/multipartFile.js +78 -0
- package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
- package/lib/cjs/decorators/params/error.js +20 -0
- package/lib/cjs/decorators/params/error.js.map +1 -0
- package/lib/cjs/decorators/params/next.js +21 -0
- package/lib/cjs/decorators/params/next.js.map +1 -0
- package/lib/cjs/decorators/params/request.js +39 -0
- package/lib/cjs/decorators/params/request.js.map +1 -0
- package/lib/cjs/decorators/params/response.js +33 -0
- package/lib/cjs/decorators/params/response.js.map +1 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +27 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/cjs/domain/ControllerProvider.js +51 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/cjs/domain/EndpointMetadata.js +6 -0
- package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
- package/lib/cjs/domain/HandlerMetadata.js +57 -0
- package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
- package/lib/cjs/domain/PlatformContext.js +92 -0
- package/lib/cjs/domain/PlatformContext.js.map +1 -0
- package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/cjs/exports.js +31 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +68 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/cjs/interfaces/AfterInit.js +3 -0
- package/lib/cjs/interfaces/AfterInit.js.map +1 -0
- package/lib/cjs/interfaces/AfterListen.js +3 -0
- package/lib/cjs/interfaces/AfterListen.js.map +1 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/BeforeInit.js +3 -0
- package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
- package/lib/cjs/interfaces/BeforeListen.js +3 -0
- package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/HandlerType.js +17 -0
- package/lib/cjs/interfaces/HandlerType.js.map +1 -0
- package/lib/cjs/interfaces/IncomingEvent.js +3 -0
- package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
- package/lib/cjs/interfaces/OnReady.js +3 -0
- package/lib/cjs/interfaces/OnReady.js.map +1 -0
- package/lib/cjs/interfaces/OnRequest.js +3 -0
- package/lib/cjs/interfaces/OnRequest.js.map +1 -0
- package/lib/cjs/interfaces/OnResponse.js +3 -0
- package/lib/cjs/interfaces/OnResponse.js.map +1 -0
- package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
- package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/cjs/interfaces/Route.js +3 -0
- package/lib/cjs/interfaces/Route.js.map +1 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +67 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FakeAdapter.js +55 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +128 -0
- package/lib/cjs/services/Platform.js.map +1 -0
- package/lib/cjs/services/PlatformAdapter.js +14 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +32 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -0
- package/lib/cjs/services/PlatformHandler.js +235 -0
- package/lib/cjs/services/PlatformHandler.js.map +1 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js +75 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/cjs/services/PlatformRequest.js +138 -0
- package/lib/cjs/services/PlatformRequest.js.map +1 -0
- package/lib/cjs/services/PlatformResponse.js +271 -0
- package/lib/cjs/services/PlatformResponse.js.map +1 -0
- package/lib/cjs/services/PlatformRouter.js +108 -0
- package/lib/cjs/services/PlatformRouter.js.map +1 -0
- package/lib/cjs/services/PlatformTest.js +173 -0
- package/lib/cjs/services/PlatformTest.js.map +1 -0
- package/lib/cjs/utils/__mock__/Test1.js +8 -0
- package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
- package/lib/cjs/utils/__mock__/Test2.js +8 -0
- package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
- package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js +12 -0
- package/lib/cjs/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/Module1.js +19 -0
- package/lib/cjs/utils/__mock__/module1/Module1.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js +17 -0
- package/lib/cjs/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js +17 -0
- package/lib/cjs/utils/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js +15 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js +12 -0
- package/lib/cjs/utils/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/cjs/utils/__mock__/module2/Module2.js +18 -0
- package/lib/cjs/utils/__mock__/module2/Module2.js.map +1 -0
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js +12 -0
- package/lib/cjs/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/cjs/utils/createContext.js +38 -0
- package/lib/cjs/utils/createContext.js.map +1 -0
- package/lib/cjs/utils/createHandlerMetadata.js +49 -0
- package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
- package/lib/cjs/utils/createHttpServer.js +29 -0
- package/lib/cjs/utils/createHttpServer.js.map +1 -0
- package/lib/cjs/utils/createHttpsServer.js +29 -0
- package/lib/cjs/utils/createHttpsServer.js.map +1 -0
- package/lib/cjs/utils/createInjector.js +46 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +46 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/getStaticsOptions.js +21 -0
- package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
- package/lib/cjs/utils/listenServer.js +21 -0
- package/lib/cjs/utils/listenServer.js.map +1 -0
- package/lib/cjs/utils/mapReturnedResponse.js +15 -0
- package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
- package/lib/cjs/utils/printRoutes.js +36 -0
- package/lib/cjs/utils/printRoutes.js.map +1 -0
- package/lib/cjs/utils/setResponseHeaders.js +35 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
- package/lib/cjs/utils/useCtxHandler.js +15 -0
- package/lib/cjs/utils/useCtxHandler.js.map +1 -0
- package/lib/esm/builder/PlatformBuilder.js +277 -0
- package/lib/esm/builder/PlatformBuilder.js.map +1 -0
- package/lib/esm/builder/PlatformControllerBuilder.js +76 -0
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
- package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/esm/config/services/PlatformConfiguration.js +184 -0
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/esm/constants/routerOptions.js +2 -0
- package/lib/esm/constants/routerOptions.js.map +1 -0
- package/lib/esm/decorators/multer/multerFileSize.js +31 -0
- package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/esm/decorators/multer/multerOptions.js +48 -0
- package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
- package/lib/esm/decorators/multer/multipartFile.js +74 -0
- package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
- package/lib/esm/decorators/params/error.js +16 -0
- package/lib/esm/decorators/params/error.js.map +1 -0
- package/lib/esm/decorators/params/next.js +17 -0
- package/lib/esm/decorators/params/next.js.map +1 -0
- package/lib/esm/decorators/params/request.js +34 -0
- package/lib/esm/decorators/params/request.js.map +1 -0
- package/lib/esm/decorators/params/response.js +28 -0
- package/lib/esm/decorators/params/response.js.map +1 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js +23 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/esm/domain/ControllerProvider.js +47 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/EndpointMetadata.js +2 -0
- package/lib/esm/domain/EndpointMetadata.js.map +1 -0
- package/lib/esm/domain/HandlerMetadata.js +53 -0
- package/lib/esm/domain/HandlerMetadata.js.map +1 -0
- package/lib/esm/domain/PlatformContext.js +88 -0
- package/lib/esm/domain/PlatformContext.js.map +1 -0
- package/lib/esm/domain/PlatformRouteDetails.js +20 -0
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/esm/exports.js +13 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +65 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/AfterInit.js +2 -0
- package/lib/esm/interfaces/AfterInit.js.map +1 -0
- package/lib/esm/interfaces/AfterListen.js +2 -0
- package/lib/esm/interfaces/AfterListen.js.map +1 -0
- package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
- package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeInit.js +2 -0
- package/lib/esm/interfaces/BeforeInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeListen.js +2 -0
- package/lib/esm/interfaces/BeforeListen.js.map +1 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/HandlerType.js +14 -0
- package/lib/esm/interfaces/HandlerType.js.map +1 -0
- package/lib/esm/interfaces/IncomingEvent.js +2 -0
- package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
- package/lib/esm/interfaces/OnReady.js +2 -0
- package/lib/esm/interfaces/OnReady.js.map +1 -0
- package/lib/esm/interfaces/OnRequest.js +2 -0
- package/lib/esm/interfaces/OnRequest.js.map +1 -0
- package/lib/esm/interfaces/OnResponse.js +2 -0
- package/lib/esm/interfaces/OnResponse.js.map +1 -0
- package/lib/esm/interfaces/OnRoutesInit.js +2 -0
- package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
- package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/esm/interfaces/Route.js +2 -0
- package/lib/esm/interfaces/Route.js.map +1 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +63 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FakeAdapter.js +51 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +125 -0
- package/lib/esm/services/Platform.js.map +1 -0
- package/lib/esm/services/PlatformAdapter.js +10 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +29 -0
- package/lib/esm/services/PlatformApplication.js.map +1 -0
- package/lib/esm/services/PlatformHandler.js +232 -0
- package/lib/esm/services/PlatformHandler.js.map +1 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js +72 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/esm/services/PlatformRequest.js +135 -0
- package/lib/esm/services/PlatformRequest.js.map +1 -0
- package/lib/esm/services/PlatformResponse.js +268 -0
- package/lib/esm/services/PlatformResponse.js.map +1 -0
- package/lib/esm/services/PlatformRouter.js +105 -0
- package/lib/esm/services/PlatformRouter.js.map +1 -0
- package/lib/esm/services/PlatformTest.js +168 -0
- package/lib/esm/services/PlatformTest.js.map +1 -0
- package/lib/esm/utils/__mock__/Test1.js +4 -0
- package/lib/esm/utils/__mock__/Test1.js.map +1 -0
- package/lib/esm/utils/__mock__/Test2.js +4 -0
- package/lib/esm/utils/__mock__/Test2.js.map +1 -0
- package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js +9 -0
- package/lib/esm/utils/__mock__/controllers/rest/TestCtrl.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/Module1.js +16 -0
- package/lib/esm/utils/__mock__/module1/Module1.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js +14 -0
- package/lib/esm/utils/__mock__/module1/controllers/M1Ctrl1.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/services/M1Service.js +14 -0
- package/lib/esm/utils/__mock__/module1/services/M1Service.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js +12 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubModule.js.map +1 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js +9 -0
- package/lib/esm/utils/__mock__/module1/submodule/SubService.js.map +1 -0
- package/lib/esm/utils/__mock__/module2/Module2.js +15 -0
- package/lib/esm/utils/__mock__/module2/Module2.js.map +1 -0
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js +9 -0
- package/lib/esm/utils/__mock__/module2/controllers/M2Ctrl.js.map +1 -0
- package/lib/esm/utils/createContext.js +34 -0
- package/lib/esm/utils/createContext.js.map +1 -0
- package/lib/esm/utils/createHandlerMetadata.js +45 -0
- package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
- package/lib/esm/utils/createHttpServer.js +24 -0
- package/lib/esm/utils/createHttpServer.js.map +1 -0
- package/lib/esm/utils/createHttpsServer.js +24 -0
- package/lib/esm/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/utils/createInjector.js +42 -0
- package/lib/esm/utils/createInjector.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +42 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/getStaticsOptions.js +17 -0
- package/lib/esm/utils/getStaticsOptions.js.map +1 -0
- package/lib/esm/utils/listenServer.js +17 -0
- package/lib/esm/utils/listenServer.js.map +1 -0
- package/lib/esm/utils/mapReturnedResponse.js +11 -0
- package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
- package/lib/esm/utils/printRoutes.js +32 -0
- package/lib/esm/utils/printRoutes.js.map +1 -0
- package/lib/esm/utils/setResponseHeaders.js +31 -0
- package/lib/esm/utils/setResponseHeaders.js.map +1 -0
- package/lib/esm/utils/useCtxHandler.js +11 -0
- package/lib/esm/utils/useCtxHandler.js.map +1 -0
- package/lib/{builder → types/builder}/PlatformBuilder.d.ts +30 -34
- package/lib/types/builder/PlatformControllerBuilder.d.ts +18 -0
- package/lib/{config → types/config}/interfaces/ConverterSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +14 -0
- package/lib/{config → types/config}/interfaces/PlatformStaticsSettings.d.ts +1 -0
- package/lib/{config → types/config}/services/PlatformConfiguration.d.ts +24 -17
- package/lib/{constants → types/constants}/routerOptions.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multerFileSize.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multerOptions.d.ts +0 -0
- package/lib/{decorators → types/decorators}/multer/multipartFile.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/error.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/next.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/request.d.ts +0 -0
- package/lib/{decorators → types/decorators}/params/response.d.ts +0 -0
- package/lib/{domain → types/domain}/AnyToPromiseWithCtx.d.ts +0 -0
- package/lib/types/domain/ControllerProvider.d.ts +24 -0
- package/lib/types/domain/EndpointMetadata.d.ts +1 -0
- package/lib/{domain → types/domain}/HandlerMetadata.d.ts +2 -2
- package/lib/{domain → types/domain}/PlatformContext.d.ts +1 -1
- package/lib/types/domain/PlatformRouteDetails.d.ts +22 -0
- package/lib/types/exports.d.ts +12 -0
- package/lib/types/index.d.ts +64 -0
- package/lib/{interfaces → types/interfaces}/AfterInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/AfterListen.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/AfterRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeListen.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/BeforeRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/HandlerType.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/IncomingEvent.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnReady.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnRequest.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnResponse.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/OnRoutesInit.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/PlatformRouteOptions.d.ts +5 -3
- package/lib/{interfaces → types/interfaces}/ResponseErrorObject.d.ts +0 -0
- package/lib/{interfaces → types/interfaces}/Route.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
- package/lib/{middlewares → types/middlewares}/PlatformMulterMiddleware.d.ts +8 -3
- package/lib/{middlewares/data → types/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +6 -0
- package/lib/types/services/FakeAdapter.d.ts +30 -0
- package/lib/{services → types/services}/Platform.d.ts +22 -7
- package/lib/types/services/PlatformAdapter.d.ts +47 -0
- package/lib/{services → types/services}/PlatformApplication.d.ts +3 -3
- package/lib/{services → types/services}/PlatformHandler.d.ts +1 -1
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +10 -0
- package/lib/{services → types/services}/PlatformRequest.d.ts +2 -1
- package/lib/{services → types/services}/PlatformResponse.d.ts +10 -10
- package/lib/{services → types/services}/PlatformRouter.d.ts +12 -8
- package/lib/{services → types/services}/PlatformTest.d.ts +6 -5
- package/lib/types/utils/__mock__/Test1.d.ts +3 -0
- package/lib/types/utils/__mock__/Test2.d.ts +3 -0
- package/lib/types/utils/__mock__/controllers/rest/TestCtrl.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/Module1.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/controllers/M1Ctrl1.d.ts +5 -0
- package/lib/types/utils/__mock__/module1/services/M1Service.d.ts +5 -0
- package/lib/types/utils/__mock__/module1/submodule/SubModule.d.ts +2 -0
- package/lib/types/utils/__mock__/module1/submodule/SubService.d.ts +2 -0
- package/lib/types/utils/__mock__/module2/Module2.d.ts +2 -0
- package/lib/types/utils/__mock__/module2/controllers/M2Ctrl.d.ts +2 -0
- package/lib/{utils → types/utils}/createContext.d.ts +0 -0
- package/lib/{utils → types/utils}/createHandlerMetadata.d.ts +1 -1
- package/lib/types/utils/createHttpServer.d.ts +4 -0
- package/lib/types/utils/createHttpsServer.d.ts +5 -0
- package/lib/types/utils/createInjector.d.ts +9 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/getStaticsOptions.d.ts +5 -0
- package/lib/types/utils/listenServer.d.ts +7 -0
- package/lib/{utils → types/utils}/mapReturnedResponse.d.ts +0 -0
- package/lib/{utils → types/utils}/printRoutes.d.ts +0 -0
- package/lib/{utils → types/utils}/setResponseHeaders.d.ts +0 -0
- package/lib/{utils → types/utils}/useCtxHandler.d.ts +0 -0
- package/package.json +47 -34
- package/readme.md +50 -57
- package/tsconfig.compile.esm.json +13 -0
- package/lib/PlatformModule.d.ts +0 -15
- package/lib/builder/PlatformControllerBuilder.d.ts +0 -19
- package/lib/config/index.d.ts +0 -3
- package/lib/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
- package/lib/config/interfaces/PlatformMulterSettings.d.ts +0 -138
- package/lib/config/interfaces/index.d.ts +0 -84
- package/lib/decorators/httpServer.d.ts +0 -27
- package/lib/decorators/httpsServer.d.ts +0 -27
- package/lib/decorators/index.d.ts +0 -13
- package/lib/decorators/method/acceptMime.d.ts +0 -19
- package/lib/decorators/method/endpointFn.d.ts +0 -8
- package/lib/decorators/method/location.d.ts +0 -1
- package/lib/decorators/method/redirect.d.ts +0 -1
- package/lib/decorators/method/route.d.ts +0 -1
- package/lib/decorators/multer/index.d.ts +0 -3
- package/lib/domain/ControllerProvider.d.ts +0 -53
- package/lib/domain/EndpointMetadata.d.ts +0 -88
- package/lib/domain/PlatformRouteDetails.d.ts +0 -29
- package/lib/domain/index.d.ts +0 -6
- package/lib/index.d.ts +0 -22
- package/lib/index.js +0 -3651
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3464
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/PathType.d.ts +0 -1
- package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
- package/lib/interfaces/index.d.ts +0 -17
- package/lib/middlewares/bindEndpointMiddleware.d.ts +0 -5
- package/lib/middlewares/index.d.ts +0 -3
- package/lib/registries/ControllerRegistry.d.ts +0 -1
- package/lib/services/FakeRawDriver.d.ts +0 -15
- package/lib/services/index.d.ts +0 -7
- package/lib/utils/createHttpServer.d.ts +0 -3
- package/lib/utils/createHttpsServer.d.ts +0 -3
- package/lib/utils/createInjector.d.ts +0 -2
- package/lib/utils/createPlatformApplication.d.ts +0 -2
- package/lib/utils/getControllerPath.d.ts +0 -2
- package/lib/utils/index.d.ts +0 -8
- package/lib/utils/listenServer.d.ts +0 -10
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformConfiguration.js","sourceRoot":"","sources":["../../../../src/config/services/PlatformConfiguration.ts"],"names":[],"mappings":"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","sourcesContent":["import {Env, getHostInfoFromPort} from \"@tsed/core\";\nimport {DIConfiguration, Injectable, ProviderScope, TokenProvider} from \"@tsed/di\";\nimport {$log} from \"@tsed/logger\";\nimport Https from \"https\";\nimport {ConverterSettings} from \"../interfaces/ConverterSettings\";\nimport {PlatformLoggerSettings} from \"../interfaces/PlatformLoggerSettings\";\n\nconst rootDir = process.cwd();\n\n/**\n * `PlatformConfiguration` contains all information about your Server configuration.\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n global: true\n})\nexport class PlatformConfiguration extends DIConfiguration {\n constructor() {\n super({rootDir});\n }\n\n get version() {\n return this.getRaw(\"version\");\n }\n\n set version(v: string) {\n this.setRaw(\"version\", v);\n }\n\n get rootDir() {\n return this.getRaw(\"rootDir\");\n }\n\n set rootDir(value: string) {\n this.setRaw(\"rootDir\", value);\n }\n\n get port(): string | number | false {\n return this.httpPort;\n }\n\n set port(value: string | number | false) {\n this.httpPort = value;\n }\n\n get httpsOptions(): Https.ServerOptions {\n return this.getRaw(\"httpsOptions\");\n }\n\n set httpsOptions(value: Https.ServerOptions) {\n this.setRaw(\"httpsOptions\", value);\n }\n\n get httpPort(): string | number | false {\n return this.getRaw(\"httpPort\");\n }\n\n set httpPort(value: string | number | false) {\n this.setRaw(\"httpPort\", value);\n }\n\n get httpsPort(): string | number | false {\n return this.getRaw(\"httpsPort\");\n }\n\n set httpsPort(value: string | number | false) {\n this.setRaw(\"httpsPort\", value);\n }\n\n get env(): Env {\n return this.getRaw(\"env\");\n }\n\n set env(value: Env) {\n this.setRaw(\"env\", value);\n }\n\n get mount(): Record<string, TokenProvider[]> {\n return this.get(\"mount\");\n }\n\n set mount(value: Record<string, TokenProvider[]>) {\n this.setRaw(\"mount\", value);\n }\n\n /**\n * @deprecated\n */\n get componentsScan(): string[] {\n return this.resolve(this.getRaw(\"componentsScan\"));\n }\n\n /**\n * @deprecated\n */\n set componentsScan(value: string[]) {\n this.setRaw(\"componentsScan\", value);\n }\n\n get statics(): Record<string, (any | string)[]> {\n return this.getRaw(\"statics\") || this.getRaw(\"serveStatic\") || {};\n }\n\n set statics(value: Record<string, (any | string)[]>) {\n this.setRaw(\"statics\", value);\n }\n\n get acceptMimes(): string[] {\n return this.getRaw(\"acceptMimes\");\n }\n\n set acceptMimes(value: string[]) {\n this.setRaw(\"acceptMimes\", value || []);\n }\n\n get debug(): boolean {\n return this.logger.level === \"debug\";\n }\n\n set debug(debug: boolean) {\n this.logger = {...this.logger, level: debug ? \"debug\" : \"info\"};\n }\n\n get converter(): Partial<ConverterSettings> {\n return this.get(\"converter\") || {};\n }\n\n set converter(options: Partial<ConverterSettings>) {\n this.setRaw(\"converter\", options);\n }\n\n get logger(): Partial<PlatformLoggerSettings> {\n return this.get(\"logger\");\n }\n\n set logger(value: Partial<PlatformLoggerSettings>) {\n const logger = {...this.logger, ...value};\n logger.debug = logger.level === \"debug\";\n\n this.setRaw(\"logger\", logger);\n this.setRaw(\"debug\", logger.debug);\n\n if (logger.format) {\n $log.appenders.set(\"stdout\", {\n type: \"stdout\",\n levels: [\"info\", \"debug\"],\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n\n $log.appenders.set(\"stderr\", {\n levels: [\"trace\", \"fatal\", \"error\", \"warn\"],\n type: \"stderr\",\n layout: {\n type: \"pattern\",\n pattern: logger.format\n }\n });\n }\n }\n\n get exclude() {\n return this.get(\"exclude\");\n }\n\n set exclude(exclude: string[]) {\n this.setRaw(\"exclude\", exclude);\n }\n\n get additionalProperties() {\n return this.get(\"converter.additionalProperties\") === \"accept\";\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpPort(): ReturnType<typeof getHostInfoFromPort> {\n return getHostInfoFromPort(\"http\", this.getRaw(\"httpPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpPort\", `${settings.address}:${settings.port}`);\n }\n\n /**\n *\n * @returns {string|number}\n */\n getHttpsPort() {\n return getHostInfoFromPort(\"https\", this.getRaw(\"httpsPort\"));\n }\n\n /**\n *\n * @param settings\n */\n setHttpsPort(settings: {address: string; port: number}) {\n this.setRaw(\"httpsPort\", `${settings.address}:${settings.port}`);\n }\n\n getBestHost() {\n const {httpsPort, httpPort} = this;\n\n if (httpsPort) {\n return this.getHttpsPort();\n }\n\n if (httpPort) {\n return this.getHttpPort();\n }\n\n return {\n toString() {\n return \"/\";\n }\n };\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routerOptions.js","sourceRoot":"","sources":["../../../src/constants/routerOptions.ts"],"names":[],"mappings":";;;AAAa,QAAA,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["export const ROUTER_OPTIONS = Symbol.for(\"ROUTER_OPTIONS\");\n"]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MulterFileSize = void 0;
|
|
4
|
+
const multerOptions_1 = require("./multerOptions");
|
|
5
|
+
/**
|
|
6
|
+
* Define file size limit.
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {Controller, Post} from "@tsed/common";
|
|
10
|
+
* import {MulterOptions, MultipartFile} from "@tsed/common";
|
|
11
|
+
* import {Multer} from "@types/multer";
|
|
12
|
+
*
|
|
13
|
+
* type MulterFile = Express.Multer.File;
|
|
14
|
+
*
|
|
15
|
+
* @Controller('/')
|
|
16
|
+
* class MyCtrl {
|
|
17
|
+
* @Post('/file2')
|
|
18
|
+
* @MulterFileSize(1024) // (Ko). Applied for all fields
|
|
19
|
+
* private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
|
|
20
|
+
*
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* > See the tutorial on the [multer configuration](/tutorials/multer.md).
|
|
26
|
+
* @param fileSize
|
|
27
|
+
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
28
|
+
* @decorator
|
|
29
|
+
* @multer
|
|
30
|
+
*/
|
|
31
|
+
function MulterFileSize(fileSize) {
|
|
32
|
+
return (0, multerOptions_1.MulterOptions)({ limits: { fileSize } });
|
|
33
|
+
}
|
|
34
|
+
exports.MulterFileSize = MulterFileSize;
|
|
35
|
+
//# sourceMappingURL=multerFileSize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multerFileSize.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multerFileSize.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,cAAc,CAAC,QAAgB;IAC7C,OAAO,IAAA,6BAAa,EAAC,EAAC,MAAM,EAAE,EAAC,QAAQ,EAAC,EAAC,CAAC,CAAC;AAC7C,CAAC;AAFD,wCAEC","sourcesContent":["import {MulterOptions} from \"./multerOptions\";\n\n/**\n * Define file size limit.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file2')\n * @MulterFileSize(1024) // (Ko). Applied for all fields\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n * @param fileSize\n * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}\n * @decorator\n * @multer\n */\nexport function MulterFileSize(fileSize: number): MethodDecorator {\n return MulterOptions({limits: {fileSize}});\n}\n"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MulterOptions = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const PlatformMulterMiddleware_1 = require("../../middlewares/PlatformMulterMiddleware");
|
|
6
|
+
/**
|
|
7
|
+
* Define multer option for all MultipartFile
|
|
8
|
+
*
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/common";
|
|
11
|
+
*
|
|
12
|
+
* @Controller('/')
|
|
13
|
+
* class MyCtrl {
|
|
14
|
+
* @Post('/file')
|
|
15
|
+
* private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
|
|
16
|
+
*
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* @Post('/file')
|
|
20
|
+
* @MulterOptions({dest: "/other-dir"})
|
|
21
|
+
* private uploadFile(@MultipartFile("file1") file: PlatformMulterFile) {
|
|
22
|
+
*
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* @Post('/file2')
|
|
26
|
+
* @MulterOptions({dest: "/other-dir"})
|
|
27
|
+
* private uploadFile(@MultipartFile("file1") file: PlatformMulterFile, @MultipartFile("file2") file2: PlatformMulterFile) {
|
|
28
|
+
*
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* @Post('/files')
|
|
32
|
+
* private uploadFile(@MultipartFile("file1") files: PlatformMulterFile[]) {
|
|
33
|
+
*
|
|
34
|
+
* }
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* See the tutorial on the [multer configuration](/tutorials/multer.md).
|
|
39
|
+
*
|
|
40
|
+
* @param {multer.Options} options
|
|
41
|
+
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
42
|
+
* @decorator
|
|
43
|
+
* @multer
|
|
44
|
+
*/
|
|
45
|
+
function MulterOptions(options) {
|
|
46
|
+
return (target, propertyKey, descriptor) => {
|
|
47
|
+
(0, core_1.StoreMerge)(PlatformMulterMiddleware_1.PlatformMulterMiddleware, { options })(target, propertyKey, descriptor);
|
|
48
|
+
return descriptor;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
exports.MulterOptions = MulterOptions;
|
|
52
|
+
//# sourceMappingURL=multerOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multerOptions.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multerOptions.ts"],"names":[],"mappings":";;;AAAA,qCAAsC;AAEtC,yFAAoF;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,SAAgB,aAAa,CAAC,OAA+B;IAC3D,OAAO,CAAC,MAAW,EAAE,WAAmB,EAAE,UAA8B,EAAE,EAAE;QAC1E,IAAA,iBAAU,EAAC,mDAAwB,EAAE,EAAC,OAAO,EAAC,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;QAEjF,OAAO,UAAU,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC;AAND,sCAMC","sourcesContent":["import {StoreMerge} from \"@tsed/core\";\nimport {PlatformMulterSettings} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\n/**\n * Define multer option for all MultipartFile\n *\n * ```typescript\n * import {Controller, Post, PlatformMulterFile, MultipartFile, MulterOptions} from \"@tsed/common\";\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: PlatformMulterFile, @MultipartFile(\"file2\") file2: PlatformMulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: PlatformMulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param {multer.Options} options\n * @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}\n * @decorator\n * @multer\n */\nexport function MulterOptions(options: PlatformMulterSettings): MethodDecorator {\n return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {\n StoreMerge(PlatformMulterMiddleware, {options})(target, propertyKey, descriptor);\n\n return descriptor;\n };\n}\n"]}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MultipartFile = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
6
|
+
const schema_1 = require("@tsed/schema");
|
|
7
|
+
const PlatformMulterMiddleware_1 = require("../../middlewares/PlatformMulterMiddleware");
|
|
8
|
+
function mapOptions(name, maxCount) {
|
|
9
|
+
return {
|
|
10
|
+
fields: [
|
|
11
|
+
{
|
|
12
|
+
name,
|
|
13
|
+
maxCount
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Define a parameter as Multipart file.
|
|
20
|
+
*
|
|
21
|
+
* ```typescript
|
|
22
|
+
* import {Controller, Post} from "@tsed/common";
|
|
23
|
+
* import {MulterOptions, MultipartFile} from "@tsed/common";
|
|
24
|
+
* import {Multer} from "@types/multer";
|
|
25
|
+
*
|
|
26
|
+
* type MulterFile = Express.Multer.File;
|
|
27
|
+
*
|
|
28
|
+
* @Controller('/')
|
|
29
|
+
* class MyCtrl {
|
|
30
|
+
* @Post('/file')
|
|
31
|
+
* private uploadFile(@MultipartFile("file1") file: MulterFile) {
|
|
32
|
+
*
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* @Post('/file')
|
|
36
|
+
* @MulterOptions({dest: "/other-dir"})
|
|
37
|
+
* private uploadFile(@MultipartFile("file1") file: MulterFile) {
|
|
38
|
+
*
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* @Post('/file2')
|
|
42
|
+
* @MulterOptions({dest: "/other-dir"})
|
|
43
|
+
* private uploadFile(@MultipartFile("file1") file: MulterFile, @MultipartFile("file2") file2: MulterFile) {
|
|
44
|
+
*
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* @Post('/files')
|
|
48
|
+
* private uploadFile(@MultipartFile("file1") files: MulterFile[]) {
|
|
49
|
+
*
|
|
50
|
+
* }
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* > See the tutorial on the [multer configuration](/tutorials/multer.md).
|
|
55
|
+
*
|
|
56
|
+
* @param name
|
|
57
|
+
* @param maxCount
|
|
58
|
+
* @returns Function
|
|
59
|
+
* @decorator
|
|
60
|
+
* @input
|
|
61
|
+
*/
|
|
62
|
+
function MultipartFile(name, maxCount) {
|
|
63
|
+
return (...args) => {
|
|
64
|
+
const [target, propertyKey, index] = args;
|
|
65
|
+
const multiple = core_1.Metadata.getParamTypes(target, propertyKey)[index] === Array;
|
|
66
|
+
name = (typeof name === "object" ? undefined : name);
|
|
67
|
+
const expression = [name, !multiple && "0"].filter(Boolean).join(".");
|
|
68
|
+
const decorators = (0, core_1.useDecorators)((0, schema_1.InFile)(name), (0, core_1.useMethodDecorators)((0, core_1.StoreMerge)(PlatformMulterMiddleware_1.PlatformMulterMiddleware, mapOptions(name, maxCount))), (0, platform_params_1.UseParam)({
|
|
69
|
+
paramType: platform_params_1.ParamTypes.FILES,
|
|
70
|
+
dataPath: "$ctx.request.files",
|
|
71
|
+
expression,
|
|
72
|
+
useValidation: true
|
|
73
|
+
}));
|
|
74
|
+
decorators(...args);
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.MultipartFile = MultipartFile;
|
|
78
|
+
//# sourceMappingURL=multipartFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":";;;AAAA,qCAAyG;AACzG,2DAA2D;AAC3D,yCAAoC;AAEpC,yFAAwG;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,IAAA,oBAAa,EAC9B,IAAA,eAAM,EAAC,IAAI,CAAC,EACZ,IAAA,0BAAmB,EAAC,IAAA,iBAAU,EAAC,mDAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrF,IAAA,0BAAQ,EAAC;YACP,SAAS,EAAE,4BAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AAtBD,sCAsBC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {InFile} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Err = void 0;
|
|
4
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
5
|
+
/**
|
|
6
|
+
* @returns {Function}
|
|
7
|
+
* @decorator
|
|
8
|
+
* @operation
|
|
9
|
+
* @input
|
|
10
|
+
*/
|
|
11
|
+
function Err() {
|
|
12
|
+
return (0, platform_params_1.UseParam)({
|
|
13
|
+
paramType: platform_params_1.ParamTypes.ERR,
|
|
14
|
+
dataPath: "err",
|
|
15
|
+
useValidation: false,
|
|
16
|
+
useConverter: false
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
exports.Err = Err;
|
|
20
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../../../src/decorators/params/error.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAE3D;;;;;GAKG;AACH,SAAgB,GAAG;IACjB,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,GAAG;QACzB,QAAQ,EAAE,KAAK;QACf,aAAa,EAAE,KAAK;QACpB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;AACL,CAAC;AAPD,kBAOC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * @returns {Function}\n * @decorator\n * @operation\n * @input\n */\nexport function Err(): Function {\n return UseParam({\n paramType: ParamTypes.ERR,\n dataPath: \"err\",\n useValidation: false,\n useConverter: false\n });\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Next = void 0;
|
|
4
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
5
|
+
/**
|
|
6
|
+
* Get the Next function (for express application and middleware).
|
|
7
|
+
*
|
|
8
|
+
* @decorator
|
|
9
|
+
* @operation
|
|
10
|
+
* @input
|
|
11
|
+
*/
|
|
12
|
+
function Next() {
|
|
13
|
+
return (0, platform_params_1.UseParam)({
|
|
14
|
+
paramType: platform_params_1.ParamTypes.NEXT_FN,
|
|
15
|
+
dataPath: "next",
|
|
16
|
+
useConverter: false,
|
|
17
|
+
useValidation: false
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.Next = Next;
|
|
21
|
+
//# sourceMappingURL=next.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next.js","sourceRoot":"","sources":["../../../../src/decorators/params/next.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAE3D;;;;;;GAMG;AACH,SAAgB,IAAI;IAClB,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,OAAO;QAC7B,QAAQ,EAAE,MAAM;QAChB,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAPD,oBAOC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\n\n/**\n * Get the Next function (for express application and middleware).\n *\n * @decorator\n * @operation\n * @input\n */\nexport function Next(): ParameterDecorator {\n return UseParam({\n paramType: ParamTypes.NEXT_FN,\n dataPath: \"next\",\n useConverter: false,\n useValidation: false\n });\n}\n\ndeclare global {\n namespace TsED {\n export interface NextFunction extends Function {}\n }\n}\n/**\n * Get the Next function (for express application and middleware).\n *\n * @decorator\n * @operation\n * @input\n */\nexport type Next = TsED.NextFunction;\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Req = exports.Request = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const http_1 = require("http");
|
|
6
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
7
|
+
function getParamType(target, propertyKey, parameterIndex) {
|
|
8
|
+
const type = core_1.Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
|
|
9
|
+
if ((0, core_1.isClass)(type)) {
|
|
10
|
+
if ((0, core_1.nameOf)(type) === "PlatformRequest") {
|
|
11
|
+
return { paramType: platform_params_1.ParamTypes.PLATFORM_REQUEST, dataPath: "$ctx.request" };
|
|
12
|
+
}
|
|
13
|
+
if (type === http_1.IncomingMessage) {
|
|
14
|
+
return { paramType: platform_params_1.ParamTypes.NODE_REQUEST, dataPath: "$ctx.request.req" };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return { paramType: platform_params_1.ParamTypes.REQUEST, dataPath: "$ctx.request.request" };
|
|
18
|
+
}
|
|
19
|
+
function Request(...args) {
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return Req(...args);
|
|
22
|
+
}
|
|
23
|
+
exports.Request = Request;
|
|
24
|
+
function Req(...args) {
|
|
25
|
+
const { expression, useType, useConverter = false, useValidation = false } = (0, platform_params_1.mapParamsOptions)(args);
|
|
26
|
+
return (target, propertyKey, parameterIndex) => {
|
|
27
|
+
const { paramType, dataPath } = getParamType(target, propertyKey, parameterIndex);
|
|
28
|
+
(0, platform_params_1.UseParam)({
|
|
29
|
+
paramType,
|
|
30
|
+
dataPath,
|
|
31
|
+
expression,
|
|
32
|
+
useType,
|
|
33
|
+
useConverter,
|
|
34
|
+
useValidation
|
|
35
|
+
})(target, propertyKey, parameterIndex);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.Req = Req;
|
|
39
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../../../src/decorators/params/request.ts"],"names":[],"mappings":";;;AAAA,qCAA2D;AAC3D,+BAAqC;AACrC,2DAA2F;AAE3F,SAAS,YAAY,CAAC,MAAc,EAAE,WAA4B,EAAE,cAAsB;IACxF,MAAM,IAAI,GAAG,eAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IAE5E,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,iBAAiB,EAAE;YACtC,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,gBAAgB,EAAE,QAAQ,EAAE,cAAc,EAAC,CAAC;SAC3E;QAED,IAAI,IAAI,KAAK,sBAAe,EAAE;YAC5B,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,kBAAkB,EAAC,CAAC;SAC3E;KACF;IAED,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAC,CAAC;AAC3E,CAAC;AAcD,SAAgB,OAAO,CAAC,GAAG,IAAW;IACpC,aAAa;IACb,OAAO,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;AACtB,CAAC;AAHD,0BAGC;AAeD,SAAgB,GAAG,CAAC,GAAG,IAAW;IAChC,MAAM,EAAC,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,aAAa,GAAG,KAAK,EAAC,GAAG,IAAA,kCAAgB,EAAC,IAAI,CAAC,CAAC;IAElG,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;QAC7C,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAEhF,IAAA,0BAAQ,EAAC;YACP,SAAS;YACT,QAAQ;YACR,UAAU;YACV,OAAO;YACP,YAAY;YACZ,aAAa;SACd,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC;AAfD,kBAeC","sourcesContent":["import {isClass, Metadata, nameOf, Type} from \"@tsed/core\";\nimport {IncomingMessage} from \"http\";\nimport {mapParamsOptions, ParamOptions, ParamTypes, UseParam} from \"@tsed/platform-params\";\n\nfunction getParamType(target: Object, propertyKey: string | symbol, parameterIndex: number) {\n const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];\n\n if (isClass(type)) {\n if (nameOf(type) === \"PlatformRequest\") {\n return {paramType: ParamTypes.PLATFORM_REQUEST, dataPath: \"$ctx.request\"};\n }\n\n if (type === IncomingMessage) {\n return {paramType: ParamTypes.NODE_REQUEST, dataPath: \"$ctx.request.req\"};\n }\n }\n\n return {paramType: ParamTypes.REQUEST, dataPath: \"$ctx.request.request\"};\n}\n\n/**\n * Request service.\n *\n * @decorator\n * @operation\n * @input\n */\nexport function Request(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Request(expression: string): ParameterDecorator;\nexport function Request(useType: Type<any>): ParameterDecorator;\nexport function Request(options: ParamOptions<any>): ParameterDecorator;\nexport function Request(): ParameterDecorator;\nexport function Request(...args: any[]): ParameterDecorator {\n // @ts-ignore\n return Req(...args);\n}\n\n/**\n * Request service.\n *\n * @alias Request\n * @decorator\n * @operation\n * @input\n */\nexport function Req(expression: string, useType: Type<any>): ParameterDecorator;\nexport function Req(expression: string): ParameterDecorator;\nexport function Req(useType: Type<any>): ParameterDecorator;\nexport function Req(options: Partial<ParamOptions>): ParameterDecorator;\nexport function Req(): ParameterDecorator;\nexport function Req(...args: any[]): ParameterDecorator {\n const {expression, useType, useConverter = false, useValidation = false} = mapParamsOptions(args);\n\n return (target, propertyKey, parameterIndex) => {\n const {paramType, dataPath} = getParamType(target, propertyKey, parameterIndex);\n\n UseParam({\n paramType,\n dataPath,\n expression,\n useType,\n useConverter,\n useValidation\n })(target, propertyKey, parameterIndex);\n };\n}\n\n/**\n * Request service.\n *\n * @decorator\n * @operation\n * @input\n */\nexport interface Request extends TsED.Request {}\n\n/**\n * Request service.\n *\n * @alias Request\n * @decorator\n * @operation\n * @input\n */\nexport interface Req extends Request {}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Res = exports.Response = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
6
|
+
const http_1 = require("http");
|
|
7
|
+
function getParamType(target, propertyKey, parameterIndex) {
|
|
8
|
+
const type = core_1.Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];
|
|
9
|
+
if ((0, core_1.isClass)(type)) {
|
|
10
|
+
if ((0, core_1.nameOf)(type) === "PlatformResponse") {
|
|
11
|
+
return { paramType: platform_params_1.ParamTypes.PLATFORM_RESPONSE, dataPath: "$ctx.response" };
|
|
12
|
+
}
|
|
13
|
+
if (type === http_1.ServerResponse) {
|
|
14
|
+
return { paramType: platform_params_1.ParamTypes.NODE_RESPONSE, dataPath: "$ctx.response.res" };
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return { paramType: platform_params_1.ParamTypes.RESPONSE, dataPath: "$ctx.response.response" };
|
|
18
|
+
}
|
|
19
|
+
function Response() {
|
|
20
|
+
return Res();
|
|
21
|
+
}
|
|
22
|
+
exports.Response = Response;
|
|
23
|
+
function Res() {
|
|
24
|
+
return (target, propertyKey, parameterIndex) => {
|
|
25
|
+
const { paramType, dataPath } = getParamType(target, propertyKey, parameterIndex);
|
|
26
|
+
(0, platform_params_1.UseParam)({
|
|
27
|
+
paramType,
|
|
28
|
+
dataPath
|
|
29
|
+
})(target, propertyKey, parameterIndex);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
exports.Res = Res;
|
|
33
|
+
//# sourceMappingURL=response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../../../src/decorators/params/response.ts"],"names":[],"mappings":";;;AAAA,qCAAqD;AACrD,2DAA2D;AAC3D,+BAAoC;AAEpC,SAAS,YAAY,CAAC,MAAc,EAAE,WAA4B,EAAE,cAAsB;IACxF,MAAM,IAAI,GAAG,eAAQ,CAAC,gBAAgB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,cAAc,CAAC,CAAC;IAE5E,IAAI,IAAA,cAAO,EAAC,IAAI,CAAC,EAAE;QACjB,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,kBAAkB,EAAE;YACvC,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,iBAAiB,EAAE,QAAQ,EAAE,eAAe,EAAC,CAAC;SAC7E;QAED,IAAI,IAAI,KAAK,qBAAc,EAAE;YAC3B,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,aAAa,EAAE,QAAQ,EAAE,mBAAmB,EAAC,CAAC;SAC7E;KACF;IAED,OAAO,EAAC,SAAS,EAAE,4BAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,wBAAwB,EAAC,CAAC;AAC9E,CAAC;AAWD,SAAgB,QAAQ;IACtB,OAAO,GAAG,EAAE,CAAC;AACf,CAAC;AAFD,4BAEC;AAYD,SAAgB,GAAG;IACjB,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,EAAE;QAC7C,MAAM,EAAC,SAAS,EAAE,QAAQ,EAAC,GAAG,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;QAChF,IAAA,0BAAQ,EAAC;YACP,SAAS;YACT,QAAQ;SACT,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;IAC1C,CAAC,CAAC;AACJ,CAAC;AARD,kBAQC","sourcesContent":["import {isClass, Metadata, nameOf} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {ServerResponse} from \"http\";\n\nfunction getParamType(target: Object, propertyKey: string | symbol, parameterIndex: number) {\n const type = Metadata.getOwnParamTypes(target, propertyKey)[parameterIndex];\n\n if (isClass(type)) {\n if (nameOf(type) === \"PlatformResponse\") {\n return {paramType: ParamTypes.PLATFORM_RESPONSE, dataPath: \"$ctx.response\"};\n }\n\n if (type === ServerResponse) {\n return {paramType: ParamTypes.NODE_RESPONSE, dataPath: \"$ctx.response.res\"};\n }\n }\n\n return {paramType: ParamTypes.RESPONSE, dataPath: \"$ctx.response.response\"};\n}\n\n/**\n * Response service.\n *\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Response(): ParameterDecorator;\nexport function Response(): ParameterDecorator {\n return Res();\n}\n\n/**\n * Request service.\n *\n * @alias Response\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport function Res(): ParameterDecorator;\nexport function Res(): ParameterDecorator {\n return (target, propertyKey, parameterIndex) => {\n const {paramType, dataPath} = getParamType(target, propertyKey, parameterIndex);\n UseParam({\n paramType,\n dataPath\n })(target, propertyKey, parameterIndex);\n };\n}\n\n/**\n * Response service.\n *\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport interface Response extends TsED.Response {}\n\n/**\n * Response service.\n *\n * @alias Response\n * @decorator\n * @operation\n * @input\n * @response\n */\nexport interface Res extends Response {}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyToPromiseWithCtx = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
class AnyToPromiseWithCtx extends core_1.AnyToPromise {
|
|
6
|
+
constructor({ $ctx, err }) {
|
|
7
|
+
super();
|
|
8
|
+
this.$ctx = $ctx;
|
|
9
|
+
this.err = err;
|
|
10
|
+
}
|
|
11
|
+
isDone() {
|
|
12
|
+
const { $ctx } = this;
|
|
13
|
+
return ($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone()) || super.isDone();
|
|
14
|
+
}
|
|
15
|
+
async call(cb) {
|
|
16
|
+
return super.call(() => cb(this));
|
|
17
|
+
}
|
|
18
|
+
destroy() {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
delete this.$ctx;
|
|
21
|
+
}
|
|
22
|
+
isCanceledResponse(process) {
|
|
23
|
+
return process === this.$ctx.getResponse();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.AnyToPromiseWithCtx = AnyToPromiseWithCtx;
|
|
27
|
+
//# sourceMappingURL=AnyToPromiseWithCtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA0D;AAW1D,MAAa,mBAAoB,SAAQ,mBAAY;IAInD,YAAY,EAAC,IAAI,EAAE,GAAG,EAAwB;QAC5C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,MAAM;QACJ,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,EAAE,KAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAY;QACrB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACL,aAAa;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF;AA5BD,kDA4BC","sourcesContent":["import {AnyPromiseResult, AnyToPromise} from \"@tsed/core\";\nimport {PlatformContext} from \"./PlatformContext\";\n\n/**\n * @ignore\n */\nexport interface HandlerContextOptions {\n $ctx: PlatformContext;\n err?: any;\n}\n\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n public err: unknown;\n\n constructor({$ctx, err}: HandlerContextOptions) {\n super();\n this.$ctx = $ctx;\n this.err = err;\n }\n\n isDone(): boolean {\n const {$ctx} = this;\n\n return $ctx?.isDone() || super.isDone();\n }\n\n async call(cb: Function): Promise<AnyPromiseResult<any>> {\n return super.call(() => cb(this));\n }\n\n destroy() {\n // @ts-ignore\n delete this.$ctx;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ControllerProvider = void 0;
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const routerOptions_1 = require("../constants/routerOptions");
|
|
6
|
+
let AUTO_INC = 0;
|
|
7
|
+
class ControllerProvider extends di_1.Provider {
|
|
8
|
+
constructor(provide, options = {}) {
|
|
9
|
+
super(provide, options);
|
|
10
|
+
this.type = di_1.ProviderType.CONTROLLER;
|
|
11
|
+
this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
get routerOptions() {
|
|
17
|
+
return this.store.get(routerOptions_1.ROUTER_OPTIONS) || {};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @param value
|
|
22
|
+
*/
|
|
23
|
+
set routerOptions(value) {
|
|
24
|
+
this.store.set(routerOptions_1.ROUTER_OPTIONS, value);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
* @returns {any[]}
|
|
29
|
+
*/
|
|
30
|
+
get middlewares() {
|
|
31
|
+
return Object.assign({
|
|
32
|
+
use: [],
|
|
33
|
+
useAfter: [],
|
|
34
|
+
useBefore: []
|
|
35
|
+
}, this.store.get("middlewares", {}));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param middlewares
|
|
40
|
+
*/
|
|
41
|
+
set middlewares(middlewares) {
|
|
42
|
+
const mdlwrs = this.middlewares;
|
|
43
|
+
const concat = (key, a, b) => (a[key] = a[key].concat(b[key]));
|
|
44
|
+
Object.keys(middlewares).forEach((key) => {
|
|
45
|
+
concat(key, mdlwrs, middlewares);
|
|
46
|
+
});
|
|
47
|
+
this.store.set("middlewares", mdlwrs);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.ControllerProvider = ControllerProvider;
|
|
51
|
+
//# sourceMappingURL=ControllerProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ControllerProvider.js","sourceRoot":"","sources":["../../../src/domain/ControllerProvider.ts"],"names":[],"mappings":";;;AAAA,iCAAsF;AACtF,8DAA0D;AAE1D,IAAI,QAAQ,GAAG,CAAC,CAAC;AAEjB,MAAa,kBAA4B,SAAQ,aAAW;IAG1D,YAAY,OAAsB,EAAE,UAA6B,EAAE;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,iBAAY,CAAC,UAAU,CAAC;QACpC,IAAI,CAAC,WAAW,GAAG,GAAG,IAAI,CAAC,IAAI,WAAW,QAAQ,EAAE,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,8BAAc,CAAC,IAAK,EAAU,CAAC;IACvD,CAAC;IAED;;;OAGG;IACH,IAAI,aAAa,CAAC,KAAU;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,8BAAc,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW;QACb,OAAO,MAAM,CAAC,MAAM,CAClB;YACE,GAAG,EAAE,EAAE;YACP,QAAQ,EAAE,EAAE;YACZ,SAAS,EAAE,EAAE;SACd,EACD,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,EAAE,CAAC,CAClC,CAAC;IACJ,CAAC;IAED;;;OAGG;IACH,IAAI,WAAW,CAAC,WAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC;QAChC,MAAM,MAAM,GAAG,CAAC,GAAW,EAAE,CAAM,EAAE,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjF,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,GAAW,EAAE,EAAE;YAC/C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;CACF;AApDD,gDAoDC","sourcesContent":["import {ControllerMiddlewares, Provider, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {ROUTER_OPTIONS} from \"../constants/routerOptions\";\n\nlet AUTO_INC = 0;\n\nexport class ControllerProvider<T = any> extends Provider<T> {\n readonly tokenRouter: string;\n\n constructor(provide: TokenProvider, options: Partial<Provider> = {}) {\n super(provide, options);\n this.type = ProviderType.CONTROLLER;\n this.tokenRouter = `${this.name}_ROUTER_${AUTO_INC++}`;\n }\n\n /**\n *\n */\n get routerOptions(): any {\n return this.store.get(ROUTER_OPTIONS) || ({} as any);\n }\n\n /**\n *\n * @param value\n */\n set routerOptions(value: any) {\n this.store.set(ROUTER_OPTIONS, value);\n }\n\n /**\n *\n * @returns {any[]}\n */\n get middlewares(): ControllerMiddlewares {\n return Object.assign(\n {\n use: [],\n useAfter: [],\n useBefore: []\n },\n this.store.get(\"middlewares\", {})\n );\n }\n\n /**\n *\n * @param middlewares\n */\n set middlewares(middlewares: ControllerMiddlewares) {\n const mdlwrs = this.middlewares;\n const concat = (key: string, a: any, b: any) => (a[key] = a[key].concat(b[key]));\n\n Object.keys(middlewares).forEach((key: string) => {\n concat(key, mdlwrs, middlewares);\n });\n this.store.set(\"middlewares\", mdlwrs);\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointMetadata = void 0;
|
|
4
|
+
var schema_1 = require("@tsed/schema");
|
|
5
|
+
Object.defineProperty(exports, "EndpointMetadata", { enumerable: true, get: function () { return schema_1.EndpointMetadata; } });
|
|
6
|
+
//# sourceMappingURL=EndpointMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA","sourcesContent":["export {EndpointMetadata} from \"@tsed/schema\";\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HandlerMetadata = void 0;
|
|
4
|
+
const core_1 = require("@tsed/core");
|
|
5
|
+
const di_1 = require("@tsed/di");
|
|
6
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
7
|
+
const schema_1 = require("@tsed/schema");
|
|
8
|
+
const HandlerType_1 = require("../interfaces/HandlerType");
|
|
9
|
+
class HandlerMetadata {
|
|
10
|
+
constructor(options) {
|
|
11
|
+
this.injectable = false;
|
|
12
|
+
this.type = HandlerType_1.HandlerType.RAW_FN;
|
|
13
|
+
this.hasNextFunction = false;
|
|
14
|
+
const { target, token, propertyKey, type, scope, routeOptions } = options;
|
|
15
|
+
this.type = type || target.type || HandlerType_1.HandlerType.RAW_FN;
|
|
16
|
+
this.scope = scope || di_1.ProviderScope.SINGLETON;
|
|
17
|
+
this.routeOptions = routeOptions || {};
|
|
18
|
+
const handler = propertyKey ? target.prototype[propertyKey] : target;
|
|
19
|
+
if (propertyKey) {
|
|
20
|
+
this.target = target;
|
|
21
|
+
this.token = token;
|
|
22
|
+
this.propertyKey = propertyKey;
|
|
23
|
+
this.hasNextFunction = this.hasParamType(platform_params_1.ParamTypes.NEXT_FN);
|
|
24
|
+
if (this.hasParamType(platform_params_1.ParamTypes.ERR)) {
|
|
25
|
+
this.type = HandlerType_1.HandlerType.ERR_MIDDLEWARE;
|
|
26
|
+
}
|
|
27
|
+
this.injectable = schema_1.JsonParameterStore.getParams(target, propertyKey).length > 0;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.handler = handler;
|
|
31
|
+
}
|
|
32
|
+
if (!this.injectable) {
|
|
33
|
+
if (handler.length === 4) {
|
|
34
|
+
this.type = HandlerType_1.HandlerType.RAW_ERR_FN;
|
|
35
|
+
}
|
|
36
|
+
this.hasNextFunction = handler.length >= 3;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get hasErrorParam() {
|
|
40
|
+
return this.type === HandlerType_1.HandlerType.ERR_MIDDLEWARE || this.type === HandlerType_1.HandlerType.RAW_ERR_FN;
|
|
41
|
+
}
|
|
42
|
+
getParams() {
|
|
43
|
+
return schema_1.JsonParameterStore.getParams(this.target, this.propertyKey) || [];
|
|
44
|
+
}
|
|
45
|
+
hasParamType(paramType) {
|
|
46
|
+
return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
|
|
47
|
+
}
|
|
48
|
+
isFinal() {
|
|
49
|
+
var _a;
|
|
50
|
+
return ((_a = this.routeOptions) === null || _a === void 0 ? void 0 : _a.isFinal) || false;
|
|
51
|
+
}
|
|
52
|
+
toString() {
|
|
53
|
+
return [this.target && (0, core_1.nameOf)(this.target), this.propertyKey].filter(Boolean).join(".");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.HandlerMetadata = HandlerMetadata;
|
|
57
|
+
//# sourceMappingURL=HandlerMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/HandlerMetadata.ts"],"names":[],"mappings":";;;AAAA,qCAAwC;AACxC,iCAAuC;AACvC,2DAAiD;AACjD,yCAAgD;AAChD,2DAAsD;AAYtD,MAAa,eAAe;IAY1B,YAAY,OAA+B;QARlC,eAAU,GAAY,KAAK,CAAC;QAC5B,SAAI,GAAgB,yBAAW,CAAC,MAAM,CAAC;QACvC,oBAAe,GAAY,KAAK,CAAC;QAOxC,MAAM,EAAC,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAAC,GAAG,OAAO,CAAC;QAExE,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,MAAM,CAAC,IAAI,IAAI,yBAAW,CAAC,MAAM,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,kBAAa,CAAC,SAAS,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,EAAE,CAAC;QACvC,MAAM,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAErE,IAAI,WAAW,EAAE;YACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,KAAK,GAAG,KAAM,CAAC;YACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;YAC/B,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,4BAAU,CAAC,OAAO,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,YAAY,CAAC,4BAAU,CAAC,GAAG,CAAC,EAAE;gBACrC,IAAI,CAAC,IAAI,GAAG,yBAAW,CAAC,cAAc,CAAC;aACxC;YAED,IAAI,CAAC,UAAU,GAAG,2BAAkB,CAAC,SAAS,CAAC,MAAa,EAAE,WAAW,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;SACvF;aAAM;YACL,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;SACxB;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;gBACxB,IAAI,CAAC,IAAI,GAAG,yBAAW,CAAC,UAAU,CAAC;aACpC;YACD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC,CAAC;SAC5C;IACH,CAAC;IAED,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,IAAI,KAAK,yBAAW,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,yBAAW,CAAC,UAAU,CAAC;IAC1F,CAAC;IAEM,SAAS;QACd,OAAO,2BAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC3E,CAAC;IAEM,YAAY,CAAC,SAAc;QAChC,OAAO,IAAI,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3E,CAAC;IAEM,OAAO;;QACZ,OAAO,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,OAAO,KAAI,KAAK,CAAC;IAC7C,CAAC;IAED,QAAQ;QACN,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,IAAA,aAAM,EAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF;AA9DD,0CA8DC","sourcesContent":["import {nameOf, Type} from \"@tsed/core\";\nimport {ProviderScope} from \"@tsed/di\";\nimport {ParamTypes} from \"@tsed/platform-params\";\nimport {JsonParameterStore} from \"@tsed/schema\";\nimport {HandlerType} from \"../interfaces/HandlerType\";\nimport {PlatformRouteOptions, PlatformRouteWithoutHandlers} from \"../interfaces/PlatformRouteOptions\";\n\nexport interface HandlerMetadataOptions {\n target: (Type<any> | Function) & {type?: HandlerType};\n routeOptions?: PlatformRouteWithoutHandlers;\n token?: Type<any>;\n propertyKey?: string | symbol;\n scope?: ProviderScope;\n type?: HandlerType;\n}\n\nexport class HandlerMetadata {\n readonly target: any;\n readonly token: Type<any>;\n readonly propertyKey: string | symbol;\n readonly injectable: boolean = false;\n readonly type: HandlerType = HandlerType.RAW_FN;\n readonly hasNextFunction: boolean = false;\n readonly routeOptions: Partial<PlatformRouteOptions>;\n readonly scope: ProviderScope;\n\n handler: any;\n\n constructor(options: HandlerMetadataOptions) {\n const {target, token, propertyKey, type, scope, routeOptions} = options;\n\n this.type = type || target.type || HandlerType.RAW_FN;\n this.scope = scope || ProviderScope.SINGLETON;\n this.routeOptions = routeOptions || {};\n const handler = propertyKey ? target.prototype[propertyKey] : target;\n\n if (propertyKey) {\n this.target = target;\n this.token = token!;\n this.propertyKey = propertyKey;\n this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);\n\n if (this.hasParamType(ParamTypes.ERR)) {\n this.type = HandlerType.ERR_MIDDLEWARE;\n }\n\n this.injectable = JsonParameterStore.getParams(target as any, propertyKey).length > 0;\n } else {\n this.handler = handler;\n }\n\n if (!this.injectable) {\n if (handler.length === 4) {\n this.type = HandlerType.RAW_ERR_FN;\n }\n this.hasNextFunction = handler.length >= 3;\n }\n }\n\n get hasErrorParam() {\n return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;\n }\n\n public getParams() {\n return JsonParameterStore.getParams(this.target, this.propertyKey) || [];\n }\n\n public hasParamType(paramType: any): boolean {\n return this.getParams().findIndex((p) => p.paramType === paramType) > -1;\n }\n\n public isFinal() {\n return this.routeOptions?.isFinal || false;\n }\n\n toString() {\n return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(\".\");\n }\n}\n"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlatformContext = void 0;
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const PlatformApplication_1 = require("../services/PlatformApplication");
|
|
6
|
+
const PlatformRequest_1 = require("../services/PlatformRequest");
|
|
7
|
+
const PlatformResponse_1 = require("../services/PlatformResponse");
|
|
8
|
+
class PlatformContext extends di_1.DIContext {
|
|
9
|
+
constructor({ event, endpoint, ignoreUrlPatterns = [], ResponseKlass = PlatformResponse_1.PlatformResponse, RequestKlass = PlatformRequest_1.PlatformRequest, ...options }) {
|
|
10
|
+
super({
|
|
11
|
+
...options,
|
|
12
|
+
ignoreLog: () => {
|
|
13
|
+
return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
this.ignoreUrlPatterns = [];
|
|
17
|
+
endpoint && (this.endpoint = endpoint);
|
|
18
|
+
this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern) => typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern);
|
|
19
|
+
this.response = new ResponseKlass(event, this);
|
|
20
|
+
this.request = new RequestKlass(event, this);
|
|
21
|
+
this.response.request = this.request;
|
|
22
|
+
this.request.response = this.response;
|
|
23
|
+
this.request.request.$ctx = this;
|
|
24
|
+
this.request.request.id = this.id;
|
|
25
|
+
this.logger.url = this.url;
|
|
26
|
+
this.container.set(PlatformResponse_1.PlatformResponse, this.response);
|
|
27
|
+
this.container.set(PlatformRequest_1.PlatformRequest, this.request);
|
|
28
|
+
this.container.set(PlatformContext, this);
|
|
29
|
+
this.response.setHeader("x-request-id", this.id);
|
|
30
|
+
}
|
|
31
|
+
get url() {
|
|
32
|
+
return this.request.url;
|
|
33
|
+
}
|
|
34
|
+
get app() {
|
|
35
|
+
return this.injector.get(PlatformApplication_1.PlatformApplication);
|
|
36
|
+
}
|
|
37
|
+
async destroy() {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
await super.destroy();
|
|
40
|
+
(_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? true : delete _b.$ctx;
|
|
41
|
+
this.response.destroy();
|
|
42
|
+
this.request.destroy();
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
delete this.endpoint;
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
delete this.response;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
delete this.request;
|
|
49
|
+
}
|
|
50
|
+
isDone() {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
if (!this.request || !this.response) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
if ((_a = this.request) === null || _a === void 0 ? void 0 : _a.isAborted()) {
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
return (_b = this.response) === null || _b === void 0 ? void 0 : _b.isDone();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Return the framework request instance (Express, Koa, etc...)
|
|
62
|
+
*/
|
|
63
|
+
getRequest() {
|
|
64
|
+
return this.request.getRequest();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Return the framework response instance (Express, Koa, etc...)
|
|
68
|
+
*/
|
|
69
|
+
getResponse() {
|
|
70
|
+
return this.response.getResponse();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get Node.js request
|
|
74
|
+
*/
|
|
75
|
+
getReq() {
|
|
76
|
+
return this.request.getReq();
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Get Node.js response
|
|
80
|
+
*/
|
|
81
|
+
getRes() {
|
|
82
|
+
return this.response.getRes();
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Return the original application instance.
|
|
86
|
+
*/
|
|
87
|
+
getApp() {
|
|
88
|
+
return this.app.getApp();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
exports.PlatformContext = PlatformContext;
|
|
92
|
+
//# sourceMappingURL=PlatformContext.js.map
|