@tsed/common 7.0.0-alpha.1 → 7.0.0-beta.10
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 +286 -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/EndpointDirectoriesSettings.js +3 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/cjs/config/services/PlatformConfiguration.js +181 -0
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/cjs/constants/routerOptions.js +5 -0
- package/lib/cjs/constants/routerOptions.js.map +1 -0
- package/lib/cjs/decorators/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 +70 -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 +167 -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/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 +42 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/cjs/utils/getStaticsOptions.js +21 -0
- package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
- package/lib/cjs/utils/importProviders.js +29 -0
- package/lib/cjs/utils/importProviders.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 +282 -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/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/services/PlatformConfiguration.js +178 -0
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/esm/constants/routerOptions.js +2 -0
- package/lib/esm/constants/routerOptions.js.map +1 -0
- package/lib/esm/decorators/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 +67 -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 +162 -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/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 +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/importProviders.js +25 -0
- package/lib/esm/utils/importProviders.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 +28 -32
- 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/EndpointDirectoriesSettings.d.ts +0 -0
- package/lib/{config → types/config}/interfaces/PlatformLoggerSettings.d.ts +0 -16
- 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 +15 -12
- 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 +2 -2
- package/lib/types/domain/PlatformRouteDetails.d.ts +22 -0
- package/lib/types/exports.d.ts +12 -0
- package/lib/types/index.d.ts +66 -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 +6 -4
- 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 +4 -9
- 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 +13 -9
- 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/{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/importProviders.d.ts +10 -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 -30
- 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/PlatformMulterSettings.d.ts +0 -138
- package/lib/config/interfaces/index.d.ts +0 -82
- package/lib/decorators/class/controller.d.ts +0 -43
- package/lib/decorators/httpServer.d.ts +0 -27
- package/lib/decorators/httpsServer.d.ts +0 -27
- package/lib/decorators/index.d.ts +0 -14
- 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 -128
- package/lib/decorators/multer/index.d.ts +0 -3
- package/lib/domain/ControllerProvider.d.ts +0 -54
- package/lib/domain/EndpointMetadata.d.ts +0 -89
- package/lib/domain/PlatformRouteDetails.d.ts +0 -29
- package/lib/domain/index.d.ts +0 -6
- package/lib/index.d.ts +0 -21
- package/lib/index.js +0 -3990
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3870
- package/lib/index.modern.js.map +0 -1
- package/lib/interfaces/PathType.d.ts +0 -1
- package/lib/interfaces/PlatformRouterMethods.d.ts +0 -10
- package/lib/interfaces/index.d.ts +0 -18
- package/lib/middlewares/PlatformLogMiddleware.d.ts +0 -44
- package/lib/middlewares/bindEndpointMiddleware.d.ts +0 -5
- package/lib/middlewares/index.d.ts +0 -4
- package/lib/registries/ControllerRegistry.d.ts +0 -1
- package/lib/services/ConverterService.d.ts +0 -27
- package/lib/services/FakeRawDriver.d.ts +0 -15
- package/lib/services/index.d.ts +0 -8
- 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,53 @@
|
|
|
1
|
+
import { nameOf } from "@tsed/core";
|
|
2
|
+
import { ProviderScope } from "@tsed/di";
|
|
3
|
+
import { ParamTypes } from "@tsed/platform-params";
|
|
4
|
+
import { JsonParameterStore } from "@tsed/schema";
|
|
5
|
+
import { HandlerType } from "../interfaces/HandlerType.js";
|
|
6
|
+
export class HandlerMetadata {
|
|
7
|
+
constructor(options) {
|
|
8
|
+
this.injectable = false;
|
|
9
|
+
this.type = HandlerType.RAW_FN;
|
|
10
|
+
this.hasNextFunction = false;
|
|
11
|
+
const { target, token, propertyKey, type, scope, routeOptions } = options;
|
|
12
|
+
this.type = type || target.type || HandlerType.RAW_FN;
|
|
13
|
+
this.scope = scope || ProviderScope.SINGLETON;
|
|
14
|
+
this.routeOptions = routeOptions || {};
|
|
15
|
+
const handler = propertyKey ? target.prototype[propertyKey] : target;
|
|
16
|
+
if (propertyKey) {
|
|
17
|
+
this.target = target;
|
|
18
|
+
this.token = token;
|
|
19
|
+
this.propertyKey = propertyKey;
|
|
20
|
+
this.hasNextFunction = this.hasParamType(ParamTypes.NEXT_FN);
|
|
21
|
+
if (this.hasParamType(ParamTypes.ERR)) {
|
|
22
|
+
this.type = HandlerType.ERR_MIDDLEWARE;
|
|
23
|
+
}
|
|
24
|
+
this.injectable = JsonParameterStore.getParams(target, propertyKey).length > 0;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.handler = handler;
|
|
28
|
+
}
|
|
29
|
+
if (!this.injectable) {
|
|
30
|
+
if (handler.length === 4) {
|
|
31
|
+
this.type = HandlerType.RAW_ERR_FN;
|
|
32
|
+
}
|
|
33
|
+
this.hasNextFunction = handler.length >= 3;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
get hasErrorParam() {
|
|
37
|
+
return this.type === HandlerType.ERR_MIDDLEWARE || this.type === HandlerType.RAW_ERR_FN;
|
|
38
|
+
}
|
|
39
|
+
getParams() {
|
|
40
|
+
return JsonParameterStore.getParams(this.target, this.propertyKey) || [];
|
|
41
|
+
}
|
|
42
|
+
hasParamType(paramType) {
|
|
43
|
+
return this.getParams().findIndex((p) => p.paramType === paramType) > -1;
|
|
44
|
+
}
|
|
45
|
+
isFinal() {
|
|
46
|
+
var _a;
|
|
47
|
+
return ((_a = this.routeOptions) === null || _a === void 0 ? void 0 : _a.isFinal) || false;
|
|
48
|
+
}
|
|
49
|
+
toString() {
|
|
50
|
+
return [this.target && nameOf(this.target), this.propertyKey].filter(Boolean).join(".");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=HandlerMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandlerMetadata.js","sourceRoot":"","sources":["../../../src/domain/HandlerMetadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAO,MAAM,YAAY,CAAC;AACxC,OAAO,EAAC,aAAa,EAAC,MAAM,UAAU,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAC,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,EAAC,WAAW,EAAC,MAAM,2BAA2B,CAAC;AAYtD,MAAM,OAAO,eAAe;IAY1B,YAAY,OAA+B;QARlC,eAAU,GAAY,KAAK,CAAC;QAC5B,SAAI,GAAgB,WAAW,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,WAAW,CAAC,MAAM,CAAC;QACtD,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,aAAa,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,UAAU,CAAC,OAAO,CAAC,CAAC;YAE7D,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;gBACrC,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC,cAAc,CAAC;aACxC;YAED,IAAI,CAAC,UAAU,GAAG,kBAAkB,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,WAAW,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,WAAW,CAAC,cAAc,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,CAAC,UAAU,CAAC;IAC1F,CAAC;IAEM,SAAS;QACd,OAAO,kBAAkB,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,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1F,CAAC;CACF","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,88 @@
|
|
|
1
|
+
import { DIContext } from "@tsed/di";
|
|
2
|
+
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
3
|
+
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
4
|
+
import { PlatformResponse } from "../services/PlatformResponse.js";
|
|
5
|
+
export class PlatformContext extends DIContext {
|
|
6
|
+
constructor({ event, endpoint, ignoreUrlPatterns = [], ResponseKlass = PlatformResponse, RequestKlass = PlatformRequest, ...options }) {
|
|
7
|
+
super({
|
|
8
|
+
...options,
|
|
9
|
+
ignoreLog: () => {
|
|
10
|
+
return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
this.ignoreUrlPatterns = [];
|
|
14
|
+
endpoint && (this.endpoint = endpoint);
|
|
15
|
+
this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern) => typeof pattern === "string" ? new RegExp(pattern, "gi") : pattern);
|
|
16
|
+
this.response = new ResponseKlass(event, this);
|
|
17
|
+
this.request = new RequestKlass(event, this);
|
|
18
|
+
this.response.request = this.request;
|
|
19
|
+
this.request.response = this.response;
|
|
20
|
+
this.request.request.$ctx = this;
|
|
21
|
+
this.request.request.id = this.id;
|
|
22
|
+
this.logger.url = this.url;
|
|
23
|
+
this.container.set(PlatformResponse, this.response);
|
|
24
|
+
this.container.set(PlatformRequest, this.request);
|
|
25
|
+
this.container.set(PlatformContext, this);
|
|
26
|
+
this.response.setHeader("x-request-id", this.id);
|
|
27
|
+
}
|
|
28
|
+
get url() {
|
|
29
|
+
return this.request.url;
|
|
30
|
+
}
|
|
31
|
+
get app() {
|
|
32
|
+
return this.injector.get(PlatformApplication);
|
|
33
|
+
}
|
|
34
|
+
async destroy() {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
await super.destroy();
|
|
37
|
+
(_b = (_a = this.request) === null || _a === void 0 ? void 0 : _a.request) === null || _b === void 0 ? true : delete _b.$ctx;
|
|
38
|
+
this.response.destroy();
|
|
39
|
+
this.request.destroy();
|
|
40
|
+
// @ts-ignore
|
|
41
|
+
delete this.endpoint;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
delete this.response;
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
delete this.request;
|
|
46
|
+
}
|
|
47
|
+
isDone() {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!this.request || !this.response) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
if ((_a = this.request) === null || _a === void 0 ? void 0 : _a.isAborted()) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
return (_b = this.response) === null || _b === void 0 ? void 0 : _b.isDone();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Return the framework request instance (Express, Koa, etc...)
|
|
59
|
+
*/
|
|
60
|
+
getRequest() {
|
|
61
|
+
return this.request.getRequest();
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Return the framework response instance (Express, Koa, etc...)
|
|
65
|
+
*/
|
|
66
|
+
getResponse() {
|
|
67
|
+
return this.response.getResponse();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Get Node.js request
|
|
71
|
+
*/
|
|
72
|
+
getReq() {
|
|
73
|
+
return this.request.getReq();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get Node.js response
|
|
77
|
+
*/
|
|
78
|
+
getRes() {
|
|
79
|
+
return this.response.getRes();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Return the original application instance.
|
|
83
|
+
*/
|
|
84
|
+
getApp() {
|
|
85
|
+
return this.app.getApp();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=PlatformContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,SAAS,EAAmB,MAAM,UAAU,CAAC;AAGrE,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAiB9D,MAAM,OAAO,eAAgB,SAAQ,SAAS;IAoB5C,YAAY,EACV,KAAK,EACL,QAAQ,EACR,iBAAiB,GAAG,EAAE,EACtB,aAAa,GAAG,gBAAgB,EAChC,YAAY,GAAG,eAAe,EAC9B,GAAG,OAAO,EACa;QACvB,KAAK,CAAC;YACJ,GAAG,OAAO;YACV,SAAS,EAAE,GAAG,EAAE;gBACd,OAAO,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;YACrE,CAAC;SACF,CAAC,CAAC;QAfG,sBAAiB,GAAa,EAAE,CAAC;QAiBvC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;QAEvC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC,OAAwB,EAAE,EAAE,CAC1E,OAAO,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAClE,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,GAAG,IAAI,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,QAAQ,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;QAEtC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClC,IAAI,CAAC,MAAM,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QAE3B,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAClD,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QAE1C,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;IAC1B,CAAC;IAED,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAsB,mBAAmB,CAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,OAAO;;QACX,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;QAEf,MAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,OAAO,+CAAE,IAAI,CAAC;QAEnC,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAEvB,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;QACrB,aAAa;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;QACrB,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM;;QACJ,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACnC,OAAO,IAAI,CAAC;SACb;QAED,IAAI,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,EAAE,EAAE;YAC7B,OAAO,IAAI,CAAC;SACb;QAED,OAAO,MAAA,IAAI,CAAC,QAAQ,0CAAE,MAAM,EAAE,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,EAAO,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAO,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;IAChC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,EAAS,CAAC;IAClC,CAAC;CACF","sourcesContent":["import {ContextMethods, DIContext, DIContextOptions} from \"@tsed/di\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformRequest} from \"../services/PlatformRequest\";\nimport {PlatformResponse} from \"../services/PlatformResponse\";\n\ndeclare global {\n namespace TsED {\n export interface Context extends PlatformContext {}\n }\n}\n\nexport interface PlatformContextOptions extends DIContextOptions {\n event: {\n response?: ServerResponse;\n request?: IncomingMessage;\n };\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext extends DIContext implements ContextMethods {\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n public endpoint: EndpointMetadata;\n /**\n * The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.\n */\n public data: any;\n /**\n * The current @@PlatformResponse@@.\n */\n public response: PlatformResponse;\n /**\n * The current @@PlatformRequest@@.\n */\n public request: PlatformRequest;\n\n private ignoreUrlPatterns: RegExp[] = [];\n\n constructor({\n event,\n endpoint,\n ignoreUrlPatterns = [],\n ResponseKlass = PlatformResponse,\n RequestKlass = PlatformRequest,\n ...options\n }: PlatformContextOptions) {\n super({\n ...options,\n ignoreLog: () => {\n return this.ignoreUrlPatterns.find((reg) => !!this.url.match(reg));\n }\n });\n\n endpoint && (this.endpoint = endpoint);\n\n this.ignoreUrlPatterns = ignoreUrlPatterns.map((pattern: string | RegExp) =>\n typeof pattern === \"string\" ? new RegExp(pattern, \"gi\") : pattern\n );\n\n this.response = new ResponseKlass(event, this);\n this.request = new RequestKlass(event, this);\n\n this.response.request = this.request;\n this.request.response = this.response;\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\n this.logger.url = this.url;\n\n this.container.set(PlatformResponse, this.response);\n this.container.set(PlatformRequest, this.request);\n this.container.set(PlatformContext, this);\n\n this.response.setHeader(\"x-request-id\", this.id);\n }\n\n get url() {\n return this.request.url;\n }\n\n get app() {\n return this.injector.get<PlatformApplication>(PlatformApplication)!;\n }\n\n async destroy() {\n await super.destroy();\n\n delete this.request?.request?.$ctx;\n\n this.response.destroy();\n this.request.destroy();\n\n // @ts-ignore\n delete this.endpoint;\n // @ts-ignore\n delete this.response;\n // @ts-ignore\n delete this.request;\n }\n\n isDone() {\n if (!this.request || !this.response) {\n return true;\n }\n\n if (this.request?.isAborted()) {\n return true;\n }\n\n return this.response?.isDone();\n }\n\n /**\n * Return the framework request instance (Express, Koa, etc...)\n */\n getRequest<Req = any>(): Req {\n return this.request.getRequest<Req>();\n }\n\n /**\n * Return the framework response instance (Express, Koa, etc...)\n */\n getResponse<Res = any>(): Res {\n return this.response.getResponse<Res>();\n }\n\n /**\n * Get Node.js request\n */\n getReq(): IncomingMessage {\n return this.request.getReq();\n }\n\n /**\n * Get Node.js response\n */\n getRes(): ServerResponse {\n return this.response.getRes();\n }\n\n /**\n * Return the original application instance.\n */\n getApp<T = any>(): T {\n return this.app.getApp() as any;\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ParamTypes } from "@tsed/platform-params";
|
|
2
|
+
import { JsonOperationRoute } from "@tsed/schema";
|
|
3
|
+
export class PlatformRouteDetails extends JsonOperationRoute {
|
|
4
|
+
constructor(options = {}) {
|
|
5
|
+
super(options);
|
|
6
|
+
this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);
|
|
7
|
+
}
|
|
8
|
+
toJSON() {
|
|
9
|
+
return {
|
|
10
|
+
method: this.method,
|
|
11
|
+
name: this.name,
|
|
12
|
+
url: this.url,
|
|
13
|
+
className: this.className,
|
|
14
|
+
methodClassName: this.methodClassName,
|
|
15
|
+
parameters: this.parameters,
|
|
16
|
+
rawBody: this.rawBody
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=PlatformRouteDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAmB,kBAAkB,EAAC,MAAM,cAAc,CAAC;AAUlE,MAAM,OAAO,oBAAqB,SAAQ,kBAAoC;IAI5E,YAAY,UAAyC,EAAE;QACrD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,OAAO,GAAG,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,UAAU,CAAC,QAAQ,CAAC,CAAC;IACrG,CAAC;IAED,MAAM;QACJ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {EndpointMetadata, JsonOperationRoute} from \"@tsed/schema\";\nimport {ControllerProvider} from \"./ControllerProvider\";\n\nexport interface PlatformRouterDetailsOptions {\n provider: ControllerProvider;\n endpoint: EndpointMetadata;\n method: string;\n url: string;\n}\n\nexport class PlatformRouteDetails extends JsonOperationRoute<EndpointMetadata> {\n readonly rawBody: boolean;\n readonly provider: ControllerProvider;\n\n constructor(options: Partial<PlatformRouteDetails> = {}) {\n super(options);\n this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === ParamTypes.RAW_BODY);\n }\n\n toJSON() {\n return {\n method: this.method,\n name: this.name,\n url: this.url,\n className: this.className,\n methodClassName: this.methodClassName,\n parameters: this.parameters,\n rawBody: this.rawBody\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import "@tsed/logger";
|
|
2
|
+
import "@tsed/logger-file";
|
|
3
|
+
export * from "@tsed/di";
|
|
4
|
+
export * from "@tsed/platform-params";
|
|
5
|
+
export * from "@tsed/platform-exceptions";
|
|
6
|
+
export * from "@tsed/platform-response-filter";
|
|
7
|
+
export * from "@tsed/platform-cache";
|
|
8
|
+
export * from "@tsed/platform-middlewares";
|
|
9
|
+
export * from "@tsed/components-scan";
|
|
10
|
+
export * from "@tsed/platform-log-middleware";
|
|
11
|
+
export { $log, Logger } from "@tsed/logger";
|
|
12
|
+
export { AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All } from "@tsed/schema";
|
|
13
|
+
//# sourceMappingURL=exports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAC;AACtB,OAAO,mBAAmB,CAAC;AAE3B,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAE9C,OAAO,EAAC,IAAI,EAAE,MAAM,EAAC,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAC,MAAM,cAAc,CAAC","sourcesContent":["import \"@tsed/logger\";\nimport \"@tsed/logger-file\";\n\nexport * from \"@tsed/di\";\nexport * from \"@tsed/platform-params\";\nexport * from \"@tsed/platform-exceptions\";\nexport * from \"@tsed/platform-response-filter\";\nexport * from \"@tsed/platform-cache\";\nexport * from \"@tsed/platform-middlewares\";\nexport * from \"@tsed/components-scan\";\nexport * from \"@tsed/platform-log-middleware\";\n\nexport {$log, Logger} from \"@tsed/logger\";\n\nexport {AcceptMime, Location, Redirect, View, Get, Post, Put, Patch, Delete, Head, Options, All} from \"@tsed/schema\";\n"]}
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
export * from "./exports.js";
|
|
5
|
+
export * from "./builder/PlatformBuilder.js";
|
|
6
|
+
export * from "./builder/PlatformControllerBuilder.js";
|
|
7
|
+
export * from "./config/interfaces/ConverterSettings.js";
|
|
8
|
+
export * from "./config/interfaces/EndpointDirectoriesSettings.js";
|
|
9
|
+
export * from "./config/interfaces/PlatformLoggerSettings.js";
|
|
10
|
+
export * from "./config/interfaces/PlatformMulterSettings.js";
|
|
11
|
+
export * from "./config/interfaces/PlatformStaticsSettings.js";
|
|
12
|
+
export * from "./config/services/PlatformConfiguration.js";
|
|
13
|
+
export * from "./constants/routerOptions.js";
|
|
14
|
+
export * from "./decorators/multer/multerFileSize.js";
|
|
15
|
+
export * from "./decorators/multer/multerOptions.js";
|
|
16
|
+
export * from "./decorators/multer/multipartFile.js";
|
|
17
|
+
export * from "./decorators/params/error.js";
|
|
18
|
+
export * from "./decorators/params/next.js";
|
|
19
|
+
export * from "./decorators/params/request.js";
|
|
20
|
+
export * from "./decorators/params/response.js";
|
|
21
|
+
export * from "./domain/AnyToPromiseWithCtx.js";
|
|
22
|
+
export * from "./domain/ControllerProvider.js";
|
|
23
|
+
export * from "./domain/EndpointMetadata.js";
|
|
24
|
+
export * from "./domain/HandlerMetadata.js";
|
|
25
|
+
export * from "./domain/PlatformContext.js";
|
|
26
|
+
export * from "./domain/PlatformRouteDetails.js";
|
|
27
|
+
export * from "./interfaces/AfterInit.js";
|
|
28
|
+
export * from "./interfaces/AfterListen.js";
|
|
29
|
+
export * from "./interfaces/AfterRoutesInit.js";
|
|
30
|
+
export * from "./interfaces/BeforeInit.js";
|
|
31
|
+
export * from "./interfaces/BeforeListen.js";
|
|
32
|
+
export * from "./interfaces/BeforeRoutesInit.js";
|
|
33
|
+
export * from "./interfaces/HandlerType.js";
|
|
34
|
+
export * from "./interfaces/IncomingEvent.js";
|
|
35
|
+
export * from "./interfaces/OnReady.js";
|
|
36
|
+
export * from "./interfaces/OnRequest.js";
|
|
37
|
+
export * from "./interfaces/OnResponse.js";
|
|
38
|
+
export * from "./interfaces/OnRoutesInit.js";
|
|
39
|
+
export * from "./interfaces/PlatformRouteOptions.js";
|
|
40
|
+
export * from "./interfaces/ResponseErrorObject.js";
|
|
41
|
+
export * from "./interfaces/Route.js";
|
|
42
|
+
export * from "./middlewares/PlatformAcceptMimesMiddleware.js";
|
|
43
|
+
export * from "./middlewares/PlatformMulterMiddleware.js";
|
|
44
|
+
export * from "./middlewares/bindEndpointMiddleware.js";
|
|
45
|
+
export * from "./services/FakeAdapter.js";
|
|
46
|
+
export * from "./services/Platform.js";
|
|
47
|
+
export * from "./services/PlatformAdapter.js";
|
|
48
|
+
export * from "./services/PlatformApplication.js";
|
|
49
|
+
export * from "./services/PlatformHandler.js";
|
|
50
|
+
export * from "./services/PlatformMiddlewaresChain.js";
|
|
51
|
+
export * from "./services/PlatformRequest.js";
|
|
52
|
+
export * from "./services/PlatformResponse.js";
|
|
53
|
+
export * from "./services/PlatformRouter.js";
|
|
54
|
+
export * from "./services/PlatformTest.js";
|
|
55
|
+
export * from "./utils/createContext.js";
|
|
56
|
+
export * from "./utils/createHandlerMetadata.js";
|
|
57
|
+
export * from "./utils/createHttpServer.js";
|
|
58
|
+
export * from "./utils/createHttpsServer.js";
|
|
59
|
+
export * from "./utils/createInjector.js";
|
|
60
|
+
export * from "./utils/getStaticsOptions.js";
|
|
61
|
+
export * from "./utils/importProviders.js";
|
|
62
|
+
export * from "./utils/listenServer.js";
|
|
63
|
+
export * from "./utils/mapReturnedResponse.js";
|
|
64
|
+
export * from "./utils/printRoutes.js";
|
|
65
|
+
export * from "./utils/setResponseHeaders.js";
|
|
66
|
+
export * from "./utils/useCtxHandler.js";
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,qCAAqC,CAAC;AACpD,cAAc,uCAAuC,CAAC;AACtD,cAAc,iDAAiD,CAAC;AAChE,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,yCAAyC,CAAC;AACxD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oCAAoC,CAAC;AACnD,cAAc,mCAAmC,CAAC;AAClD,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,6CAA6C,CAAC;AAC5D,cAAc,wCAAwC,CAAC;AACvD,cAAc,sCAAsC,CAAC;AACrD,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qCAAqC,CAAC;AACpD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/EndpointDirectoriesSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/HandlerMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./middlewares/bindEndpointMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformRouter\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHandlerMetadata\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/importProviders\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\nexport * from \"./utils/useCtxHandler\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AfterInit.js","sourceRoot":"","sources":["../../../src/interfaces/AfterInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface AfterInit {\n $afterInit(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AfterListen.js","sourceRoot":"","sources":["../../../src/interfaces/AfterListen.ts"],"names":[],"mappings":"","sourcesContent":["export interface AfterListen {\n $afterListen(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AfterRoutesInit.js","sourceRoot":"","sources":["../../../src/interfaces/AfterRoutesInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface AfterRoutesInit {\n $afterRoutesInit(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeforeInit.js","sourceRoot":"","sources":["../../../src/interfaces/BeforeInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface BeforeInit {\n $beforeInit(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeforeListen.js","sourceRoot":"","sources":["../../../src/interfaces/BeforeListen.ts"],"names":[],"mappings":"","sourcesContent":["export interface BeforeListen {\n $beforeListen(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BeforeRoutesInit.js","sourceRoot":"","sources":["../../../src/interfaces/BeforeRoutesInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface BeforeRoutesInit {\n $beforeRoutesInit(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ignore
|
|
3
|
+
*/
|
|
4
|
+
export var HandlerType;
|
|
5
|
+
(function (HandlerType) {
|
|
6
|
+
HandlerType["CUSTOM"] = "custom";
|
|
7
|
+
HandlerType["ENDPOINT"] = "endpoint";
|
|
8
|
+
HandlerType["MIDDLEWARE"] = "middleware";
|
|
9
|
+
HandlerType["ERR_MIDDLEWARE"] = "err:middleware";
|
|
10
|
+
HandlerType["CTX_FN"] = "context";
|
|
11
|
+
HandlerType["RAW_FN"] = "raw:middleware";
|
|
12
|
+
HandlerType["RAW_ERR_FN"] = "raw:err:middleware";
|
|
13
|
+
})(HandlerType || (HandlerType = {}));
|
|
14
|
+
//# sourceMappingURL=HandlerType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HandlerType.js","sourceRoot":"","sources":["../../../src/interfaces/HandlerType.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAN,IAAY,WAQX;AARD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,oCAAqB,CAAA;IACrB,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;IACjC,iCAAkB,CAAA;IAClB,wCAAyB,CAAA;IACzB,gDAAiC,CAAA;AACnC,CAAC,EARW,WAAW,KAAX,WAAW,QAQtB","sourcesContent":["/**\n * @ignore\n */\nexport enum HandlerType {\n CUSTOM = \"custom\",\n ENDPOINT = \"endpoint\",\n MIDDLEWARE = \"middleware\",\n ERR_MIDDLEWARE = \"err:middleware\",\n CTX_FN = \"context\",\n RAW_FN = \"raw:middleware\",\n RAW_ERR_FN = \"raw:err:middleware\"\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IncomingEvent.js","sourceRoot":"","sources":["../../../src/interfaces/IncomingEvent.ts"],"names":[],"mappings":"","sourcesContent":["import {IncomingMessage, ServerResponse} from \"http\";\n\nexport interface IncomingEvent<Req = IncomingMessage, Res = ServerResponse> extends Record<string, unknown> {\n response: Res;\n request: Req;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnReady.js","sourceRoot":"","sources":["../../../src/interfaces/OnReady.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnReady {\n $onReady(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnRequest.js","sourceRoot":"","sources":["../../../src/interfaces/OnRequest.ts"],"names":[],"mappings":"","sourcesContent":["import {PlatformContext} from \"../domain/PlatformContext\";\n\nexport interface OnRequest {\n $onRequest(ctx: PlatformContext): void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnResponse.js","sourceRoot":"","sources":["../../../src/interfaces/OnResponse.ts"],"names":[],"mappings":"","sourcesContent":["import {PlatformResponse} from \"../services/PlatformResponse\";\n\nexport interface OnResponse {\n $onResponse(ctx: PlatformResponse): void;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OnRoutesInit.js","sourceRoot":"","sources":["../../../src/interfaces/OnRoutesInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnRoutesInit {\n $onRoutesInit(): void | Promise<any>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"@tsed/di\";\n\n/**\n * @ignore\n */\nexport interface PlatformRouteOptions {\n token?: Type<any>;\n path?: PathType | undefined;\n method?: string;\n isFinal?: boolean;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponseErrorObject.js","sourceRoot":"","sources":["../../../src/interfaces/ResponseErrorObject.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Interface can be implemented to customize the error sent to the client.\n */\nexport interface ResponseErrorObject extends Error {\n errors?: Error[] | Error | any;\n origin?: Error;\n headers?: {};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"@tsed/di\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: ControllerProvider;\n}\n"]}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { uniq } from "@tsed/core";
|
|
3
|
+
import { Constant } from "@tsed/di";
|
|
4
|
+
import { NotAcceptable } from "@tsed/exceptions";
|
|
5
|
+
import { Middleware } from "@tsed/platform-middlewares";
|
|
6
|
+
import { Context } from "@tsed/platform-params";
|
|
7
|
+
/**
|
|
8
|
+
* @middleware
|
|
9
|
+
* @platform
|
|
10
|
+
*/
|
|
11
|
+
let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
|
|
12
|
+
use(ctx) {
|
|
13
|
+
const { endpoint, request } = ctx;
|
|
14
|
+
const mimes = uniq(((endpoint === null || endpoint === void 0 ? void 0 : endpoint.get("acceptMimes")) || []).concat(this.acceptMimes));
|
|
15
|
+
if (mimes.length && !request.accepts(mimes)) {
|
|
16
|
+
throw new NotAcceptable(mimes.join(", "));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
__decorate([
|
|
21
|
+
Constant("acceptMimes", []),
|
|
22
|
+
__metadata("design:type", Array)
|
|
23
|
+
], PlatformAcceptMimesMiddleware.prototype, "acceptMimes", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
__param(0, Context()),
|
|
26
|
+
__metadata("design:type", Function),
|
|
27
|
+
__metadata("design:paramtypes", [Object]),
|
|
28
|
+
__metadata("design:returntype", void 0)
|
|
29
|
+
], PlatformAcceptMimesMiddleware.prototype, "use", null);
|
|
30
|
+
PlatformAcceptMimesMiddleware = __decorate([
|
|
31
|
+
Middleware()
|
|
32
|
+
], PlatformAcceptMimesMiddleware);
|
|
33
|
+
export { PlatformAcceptMimesMiddleware };
|
|
34
|
+
//# sourceMappingURL=PlatformAcceptMimesMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAClC,OAAO,EAAC,aAAa,EAAC,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAIjC,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,aAAa,CAAC,KAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF,CAAA;AAVC;IADC,QAAQ,CAAC,aAAa,EAAE,EAAE,CAAC;;kEACN;AAEtB;IAAY,WAAA,OAAO,EAAE,CAAA;;;;wDAOpB;AAXU,6BAA6B;IADzC,UAAU,EAAE;GACA,6BAA6B,CAYzC;SAZY,6BAA6B","sourcesContent":["import {uniq} from \"@tsed/core\";\nimport {Constant} from \"@tsed/di\";\nimport {NotAcceptable} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\n\n/**\n * @middleware\n * @platform\n */\n@Middleware()\nexport class PlatformAcceptMimesMiddleware implements MiddlewareMethods {\n @Constant(\"acceptMimes\", [])\n acceptMimes: string[];\n\n public use(@Context() ctx: Context): void {\n const {endpoint, request} = ctx;\n const mimes = uniq((endpoint?.get(\"acceptMimes\") || []).concat(this.acceptMimes));\n\n if (mimes.length && !request.accepts(mimes)) {\n throw new NotAcceptable(mimes.join(\", \"));\n }\n }\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var PlatformMulterMiddleware_1;
|
|
2
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
+
import { Inject, Value } from "@tsed/di";
|
|
4
|
+
import { BadRequest } from "@tsed/exceptions";
|
|
5
|
+
import { Middleware } from "@tsed/platform-middlewares";
|
|
6
|
+
import { Context } from "@tsed/platform-params";
|
|
7
|
+
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
8
|
+
export class MulterException extends BadRequest {
|
|
9
|
+
constructor(er) {
|
|
10
|
+
super(er.message);
|
|
11
|
+
this.origin = er;
|
|
12
|
+
this.name = er.code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @middleware
|
|
17
|
+
*/
|
|
18
|
+
let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulterMiddleware {
|
|
19
|
+
async use(ctx) {
|
|
20
|
+
try {
|
|
21
|
+
const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware_1);
|
|
22
|
+
const settings = {
|
|
23
|
+
...this.settings,
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
/* istanbul ignore next */
|
|
27
|
+
if (settings.storage) {
|
|
28
|
+
delete settings.dest;
|
|
29
|
+
}
|
|
30
|
+
const middleware = this.app.multer(settings).fields(this.getFields({ fields }));
|
|
31
|
+
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
32
|
+
}
|
|
33
|
+
catch (er) {
|
|
34
|
+
if (er.code) {
|
|
35
|
+
throw new MulterException(er);
|
|
36
|
+
}
|
|
37
|
+
throw er;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
getFields(conf) {
|
|
41
|
+
return conf.fields.map(({ name, maxCount }) => ({ name, maxCount }));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
__decorate([
|
|
45
|
+
Value("multer", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840
|
|
46
|
+
,
|
|
47
|
+
__metadata("design:type", Object)
|
|
48
|
+
], PlatformMulterMiddleware.prototype, "settings", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
Inject(),
|
|
51
|
+
__metadata("design:type", PlatformApplication)
|
|
52
|
+
], PlatformMulterMiddleware.prototype, "app", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
__param(0, Context()),
|
|
55
|
+
__metadata("design:type", Function),
|
|
56
|
+
__metadata("design:paramtypes", [Object]),
|
|
57
|
+
__metadata("design:returntype", Promise)
|
|
58
|
+
], PlatformMulterMiddleware.prototype, "use", null);
|
|
59
|
+
PlatformMulterMiddleware = PlatformMulterMiddleware_1 = __decorate([
|
|
60
|
+
Middleware()
|
|
61
|
+
], PlatformMulterMiddleware);
|
|
62
|
+
export { PlatformMulterMiddleware };
|
|
63
|
+
//# sourceMappingURL=PlatformMulterMiddleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;AACA,OAAO,EAAW,MAAM,EAAE,KAAK,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAC,UAAU,EAAoB,MAAM,4BAA4B,CAAC;AACzE,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAE9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,iCAAiC,CAAC;AAOpE,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAOnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,MAAM,EAAE;8BACM,mBAAmB;qDAAC;AAEnC;IAAW,WAAA,OAAO,EAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,UAAU,EAAE;GACA,wBAAwB,CAmCpC;SAnCY,wBAAwB","sourcesContent":["import type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeCtrl.js","sourceRoot":"","sources":["../../../../src/middlewares/__mock__/FakeCtrl.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC;AAGpC,IAAa,QAAQ,GAArB,MAAa,QAAQ;CAAG,CAAA;AAAX,QAAQ;IADpB,UAAU,CAAC,GAAG,CAAC;GACH,QAAQ,CAAG;SAAX,QAAQ","sourcesContent":["import {Controller} from \"@tsed/di\";\n\n@Controller(\"/\")\nexport class FakeCtrl {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport type {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function bindEndpointMiddleware(endpoint: EndpointMetadata) {\n return (ctx: PlatformContext) => {\n ctx.endpoint = endpoint;\n };\n}\n"]}
|