@tsed/common 6.88.1 → 6.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{PlatformModule.d.ts → cjs/PlatformModule.d.ts} +0 -0
- package/lib/cjs/PlatformModule.js +11 -0
- package/lib/cjs/PlatformModule.js.map +1 -0
- package/lib/{builder → cjs/builder}/PlatformBuilder.d.ts +15 -27
- package/lib/cjs/builder/PlatformBuilder.js +275 -0
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -0
- package/lib/{builder → cjs/builder}/PlatformControllerBuilder.d.ts +0 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js +85 -0
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/{config → cjs/config}/index.d.ts +0 -0
- package/lib/cjs/config/index.js +7 -0
- package/lib/cjs/config/index.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/ConverterSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js +3 -0
- package/lib/cjs/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/EndpointDirectoriesSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +3 -0
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformLoggerSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformMulterSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/PlatformStaticsSettings.d.ts +0 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js +3 -0
- package/lib/cjs/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/{config → cjs/config}/interfaces/index.d.ts +10 -1
- package/lib/cjs/config/interfaces/index.js +8 -0
- package/lib/cjs/config/interfaces/index.js.map +1 -0
- package/lib/{config → cjs/config}/services/PlatformConfiguration.d.ts +9 -13
- package/lib/cjs/config/services/PlatformConfiguration.js +178 -0
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/{constants → cjs/constants}/routerOptions.d.ts +0 -0
- package/lib/cjs/constants/routerOptions.js +5 -0
- package/lib/cjs/constants/routerOptions.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/httpServer.d.ts +1 -0
- package/lib/cjs/decorators/httpServer.js +32 -0
- package/lib/cjs/decorators/httpServer.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/httpsServer.d.ts +1 -0
- package/lib/cjs/decorators/httpsServer.js +32 -0
- package/lib/cjs/decorators/httpsServer.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/index.d.ts +0 -0
- package/lib/cjs/decorators/index.js +23 -0
- package/lib/cjs/decorators/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/acceptMime.d.ts +0 -0
- package/lib/cjs/decorators/method/acceptMime.js +28 -0
- package/lib/cjs/decorators/method/acceptMime.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/endpointFn.d.ts +0 -0
- package/lib/cjs/decorators/method/endpointFn.js +15 -0
- package/lib/cjs/decorators/method/endpointFn.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/location.d.ts +0 -0
- package/lib/cjs/decorators/method/location.js +6 -0
- package/lib/cjs/decorators/method/location.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/redirect.d.ts +0 -0
- package/lib/cjs/decorators/method/redirect.js +6 -0
- package/lib/cjs/decorators/method/redirect.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/route.d.ts +0 -0
- package/lib/cjs/decorators/method/route.js +13 -0
- package/lib/cjs/decorators/method/route.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/method/view.d.ts +0 -0
- package/lib/cjs/decorators/method/view.js +34 -0
- package/lib/cjs/decorators/method/view.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/index.d.ts +0 -0
- package/lib/cjs/decorators/multer/index.js +7 -0
- package/lib/cjs/decorators/multer/index.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multerFileSize.d.ts +0 -0
- package/lib/cjs/decorators/multer/multerFileSize.js +35 -0
- package/lib/cjs/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multerOptions.d.ts +0 -0
- package/lib/cjs/decorators/multer/multerOptions.js +52 -0
- package/lib/cjs/decorators/multer/multerOptions.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/multer/multipartFile.d.ts +0 -0
- package/lib/cjs/decorators/multer/multipartFile.js +78 -0
- package/lib/cjs/decorators/multer/multipartFile.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/endpointInfo.d.ts +0 -0
- package/lib/cjs/decorators/params/endpointInfo.js +21 -0
- package/lib/cjs/decorators/params/endpointInfo.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/error.d.ts +0 -0
- package/lib/cjs/decorators/params/error.js +20 -0
- package/lib/cjs/decorators/params/error.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/next.d.ts +0 -0
- package/lib/cjs/decorators/params/next.js +21 -0
- package/lib/cjs/decorators/params/next.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/request.d.ts +0 -0
- package/lib/cjs/decorators/params/request.js +39 -0
- package/lib/cjs/decorators/params/request.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/response.d.ts +0 -0
- package/lib/cjs/decorators/params/response.js +33 -0
- package/lib/cjs/decorators/params/response.js.map +1 -0
- package/lib/{decorators → cjs/decorators}/params/responseData.d.ts +0 -0
- package/lib/cjs/decorators/params/responseData.js +21 -0
- package/lib/cjs/decorators/params/responseData.js.map +1 -0
- package/lib/{domain → cjs/domain}/AnyToPromiseWithCtx.d.ts +0 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +35 -0
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/{domain → cjs/domain}/ControllerProvider.d.ts +0 -0
- package/lib/cjs/domain/ControllerProvider.js +51 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/{domain → cjs/domain}/EndpointMetadata.d.ts +0 -0
- package/lib/cjs/domain/EndpointMetadata.js +111 -0
- package/lib/cjs/domain/EndpointMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/HandlerMetadata.d.ts +0 -0
- package/lib/cjs/domain/HandlerMetadata.js +57 -0
- package/lib/cjs/domain/HandlerMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/PlatformContext.d.ts +0 -0
- package/lib/cjs/domain/PlatformContext.js +85 -0
- package/lib/cjs/domain/PlatformContext.js.map +1 -0
- package/lib/{domain → cjs/domain}/PlatformRouteDetails.d.ts +0 -0
- package/lib/cjs/domain/PlatformRouteDetails.js +24 -0
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/{domain → cjs/domain}/PropertyMetadata.d.ts +0 -0
- package/lib/cjs/domain/PropertyMetadata.js +28 -0
- package/lib/cjs/domain/PropertyMetadata.js.map +1 -0
- package/lib/{domain → cjs/domain}/index.d.ts +0 -0
- package/lib/cjs/domain/index.js +11 -0
- package/lib/cjs/domain/index.js.map +1 -0
- package/lib/{index.d.ts → cjs/index.d.ts} +0 -0
- package/lib/cjs/index.js +37 -0
- package/lib/cjs/index.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterInit.d.ts +0 -0
- package/lib/cjs/interfaces/AfterInit.js +3 -0
- package/lib/cjs/interfaces/AfterInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterListen.d.ts +0 -0
- package/lib/cjs/interfaces/AfterListen.js +3 -0
- package/lib/cjs/interfaces/AfterListen.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/AfterRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js +3 -0
- package/lib/cjs/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeInit.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeInit.js +3 -0
- package/lib/cjs/interfaces/BeforeInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeListen.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeListen.js +3 -0
- package/lib/cjs/interfaces/BeforeListen.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/BeforeRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js +3 -0
- package/lib/cjs/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/HandlerType.d.ts +0 -0
- package/lib/cjs/interfaces/HandlerType.js +17 -0
- package/lib/cjs/interfaces/HandlerType.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/IncomingEvent.d.ts +0 -0
- package/lib/cjs/interfaces/IncomingEvent.js +3 -0
- package/lib/cjs/interfaces/IncomingEvent.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnReady.d.ts +0 -0
- package/lib/cjs/interfaces/OnReady.js +3 -0
- package/lib/cjs/interfaces/OnReady.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnRequest.d.ts +0 -0
- package/lib/cjs/interfaces/OnRequest.js +3 -0
- package/lib/cjs/interfaces/OnRequest.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnResponse.d.ts +0 -0
- package/lib/cjs/interfaces/OnResponse.js +3 -0
- package/lib/cjs/interfaces/OnResponse.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/OnRoutesInit.d.ts +0 -0
- package/lib/cjs/interfaces/OnRoutesInit.js +3 -0
- package/lib/cjs/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PathType.d.ts +0 -0
- package/lib/cjs/interfaces/PathType.js +3 -0
- package/lib/cjs/interfaces/PathType.js.map +1 -0
- package/lib/cjs/interfaces/PlatformAdapter.d.ts +19 -0
- package/lib/cjs/interfaces/PlatformAdapter.js +3 -0
- package/lib/cjs/interfaces/PlatformAdapter.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/PlatformRouteOptions.d.ts +0 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js +3 -0
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/ResponseErrorObject.d.ts +0 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js +3 -0
- package/lib/cjs/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/Route.d.ts +0 -0
- package/lib/cjs/interfaces/Route.js +3 -0
- package/lib/cjs/interfaces/Route.js.map +1 -0
- package/lib/{interfaces → cjs/interfaces}/index.d.ts +1 -0
- package/lib/cjs/interfaces/index.js +21 -0
- package/lib/cjs/interfaces/index.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/AcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/AcceptMimesMiddleware.js +27 -0
- package/lib/cjs/middlewares/AcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/GlobalAcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js +26 -0
- package/lib/cjs/middlewares/GlobalAcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/PlatformAcceptMimesMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +37 -0
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/PlatformMulterMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +55 -0
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/{middlewares/data → cjs/middlewares/__mock__}/FakeCtrl.d.ts +0 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +12 -0
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/bindEndpointMiddleware.d.ts +0 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +13 -0
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/{middlewares → cjs/middlewares}/index.d.ts +0 -0
- package/lib/cjs/middlewares/index.js +9 -0
- package/lib/cjs/middlewares/index.js.map +1 -0
- package/lib/{services → cjs/services}/FakeRawDriver.d.ts +0 -0
- package/lib/cjs/services/FakeRawDriver.js +26 -0
- package/lib/cjs/services/FakeRawDriver.js.map +1 -0
- package/lib/{services → cjs/services}/Platform.d.ts +0 -0
- package/lib/cjs/services/Platform.js +107 -0
- package/lib/cjs/services/Platform.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformApplication.d.ts +0 -0
- package/lib/cjs/services/PlatformApplication.js +34 -0
- package/lib/cjs/services/PlatformApplication.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformHandler.d.ts +0 -0
- package/lib/cjs/services/PlatformHandler.js +235 -0
- package/lib/cjs/services/PlatformHandler.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformMiddlewaresChain.d.ts +0 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js +34 -0
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformRequest.d.ts +0 -0
- package/lib/cjs/services/PlatformRequest.js +138 -0
- package/lib/cjs/services/PlatformRequest.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformResponse.d.ts +0 -0
- package/lib/cjs/services/PlatformResponse.js +271 -0
- package/lib/cjs/services/PlatformResponse.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformRouter.d.ts +0 -0
- package/lib/cjs/services/PlatformRouter.js +126 -0
- package/lib/cjs/services/PlatformRouter.js.map +1 -0
- package/lib/{services → cjs/services}/PlatformTest.d.ts +5 -4
- package/lib/cjs/services/PlatformTest.js +167 -0
- package/lib/cjs/services/PlatformTest.js.map +1 -0
- package/lib/{services → cjs/services}/index.d.ts +0 -0
- package/lib/cjs/services/index.js +12 -0
- package/lib/cjs/services/index.js.map +1 -0
- package/lib/{utils → cjs/utils}/createContext.d.ts +0 -0
- package/lib/cjs/utils/createContext.js +38 -0
- package/lib/cjs/utils/createContext.js.map +1 -0
- package/lib/{utils → cjs/utils}/createHandlerMetadata.d.ts +0 -0
- package/lib/cjs/utils/createHandlerMetadata.js +49 -0
- package/lib/cjs/utils/createHandlerMetadata.js.map +1 -0
- package/lib/cjs/utils/createHttpServer.d.ts +4 -0
- package/lib/cjs/utils/createHttpServer.js +34 -0
- package/lib/cjs/utils/createHttpServer.js.map +1 -0
- package/lib/cjs/utils/createHttpsServer.d.ts +4 -0
- package/lib/cjs/utils/createHttpsServer.js +34 -0
- package/lib/cjs/utils/createHttpsServer.js.map +1 -0
- package/lib/{utils → cjs/utils}/createInjector.d.ts +0 -0
- package/lib/cjs/utils/createInjector.js +38 -0
- package/lib/cjs/utils/createInjector.js.map +1 -0
- package/lib/{utils → cjs/utils}/getConfiguration.d.ts +0 -0
- package/lib/cjs/utils/getConfiguration.js +42 -0
- package/lib/cjs/utils/getConfiguration.js.map +1 -0
- package/lib/{utils → cjs/utils}/getStaticsOptions.d.ts +0 -0
- package/lib/cjs/utils/getStaticsOptions.js +21 -0
- package/lib/cjs/utils/getStaticsOptions.js.map +1 -0
- package/lib/{utils → cjs/utils}/index.d.ts +0 -0
- package/lib/cjs/utils/index.js +12 -0
- package/lib/cjs/utils/index.js.map +1 -0
- package/lib/cjs/utils/listenServer.d.ts +7 -0
- package/lib/cjs/utils/listenServer.js +21 -0
- package/lib/cjs/utils/listenServer.js.map +1 -0
- package/lib/{utils → cjs/utils}/loadInjector.d.ts +0 -0
- package/lib/cjs/utils/loadInjector.js +14 -0
- package/lib/cjs/utils/loadInjector.js.map +1 -0
- package/lib/{utils → cjs/utils}/mapReturnedResponse.d.ts +0 -0
- package/lib/cjs/utils/mapReturnedResponse.js +15 -0
- package/lib/cjs/utils/mapReturnedResponse.js.map +1 -0
- package/lib/{utils → cjs/utils}/printRoutes.d.ts +0 -0
- package/lib/cjs/utils/printRoutes.js +36 -0
- package/lib/cjs/utils/printRoutes.js.map +1 -0
- package/lib/{utils → cjs/utils}/setResponseHeaders.d.ts +0 -0
- package/lib/cjs/utils/setResponseHeaders.js +35 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -0
- package/lib/{utils → cjs/utils}/useCtxHandler.d.ts +0 -0
- package/lib/cjs/utils/useCtxHandler.js +15 -0
- package/lib/cjs/utils/useCtxHandler.js.map +1 -0
- package/lib/esm/PlatformModule.js +7 -0
- package/lib/esm/PlatformModule.js.map +1 -0
- package/lib/esm/builder/PlatformBuilder.js +271 -0
- package/lib/esm/builder/PlatformBuilder.js.map +1 -0
- package/lib/esm/builder/PlatformControllerBuilder.js +79 -0
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -0
- package/lib/esm/config/index.js +4 -0
- package/lib/esm/config/index.js.map +1 -0
- package/lib/esm/config/interfaces/ConverterSettings.js +2 -0
- package/lib/esm/config/interfaces/ConverterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +2 -0
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js +2 -0
- package/lib/esm/config/interfaces/PlatformStaticsSettings.js.map +1 -0
- package/lib/esm/config/interfaces/index.js +5 -0
- package/lib/esm/config/interfaces/index.js.map +1 -0
- package/lib/esm/config/services/PlatformConfiguration.js +175 -0
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -0
- package/lib/esm/constants/routerOptions.js +2 -0
- package/lib/esm/constants/routerOptions.js.map +1 -0
- package/lib/esm/decorators/httpServer.js +28 -0
- package/lib/esm/decorators/httpServer.js.map +1 -0
- package/lib/esm/decorators/httpsServer.js +28 -0
- package/lib/esm/decorators/httpsServer.js.map +1 -0
- package/lib/esm/decorators/index.js +20 -0
- package/lib/esm/decorators/index.js.map +1 -0
- package/lib/esm/decorators/method/acceptMime.js +24 -0
- package/lib/esm/decorators/method/acceptMime.js.map +1 -0
- package/lib/esm/decorators/method/endpointFn.js +11 -0
- package/lib/esm/decorators/method/endpointFn.js.map +1 -0
- package/lib/esm/decorators/method/location.js +2 -0
- package/lib/esm/decorators/method/location.js.map +1 -0
- package/lib/esm/decorators/method/redirect.js +2 -0
- package/lib/esm/decorators/method/redirect.js.map +1 -0
- package/lib/esm/decorators/method/route.js +2 -0
- package/lib/esm/decorators/method/route.js.map +1 -0
- package/lib/esm/decorators/method/view.js +30 -0
- package/lib/esm/decorators/method/view.js.map +1 -0
- package/lib/esm/decorators/multer/index.js +4 -0
- package/lib/esm/decorators/multer/index.js.map +1 -0
- package/lib/esm/decorators/multer/multerFileSize.js +31 -0
- package/lib/esm/decorators/multer/multerFileSize.js.map +1 -0
- package/lib/esm/decorators/multer/multerOptions.js +48 -0
- package/lib/esm/decorators/multer/multerOptions.js.map +1 -0
- package/lib/esm/decorators/multer/multipartFile.js +74 -0
- package/lib/esm/decorators/multer/multipartFile.js.map +1 -0
- package/lib/esm/decorators/params/endpointInfo.js +17 -0
- package/lib/esm/decorators/params/endpointInfo.js.map +1 -0
- package/lib/esm/decorators/params/error.js +16 -0
- package/lib/esm/decorators/params/error.js.map +1 -0
- package/lib/esm/decorators/params/next.js +17 -0
- package/lib/esm/decorators/params/next.js.map +1 -0
- package/lib/esm/decorators/params/request.js +34 -0
- package/lib/esm/decorators/params/request.js.map +1 -0
- package/lib/esm/decorators/params/response.js +28 -0
- package/lib/esm/decorators/params/response.js.map +1 -0
- package/lib/esm/decorators/params/responseData.js +17 -0
- package/lib/esm/decorators/params/responseData.js.map +1 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js +31 -0
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -0
- package/lib/esm/domain/ControllerProvider.js +47 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/EndpointMetadata.js +108 -0
- package/lib/esm/domain/EndpointMetadata.js.map +1 -0
- package/lib/esm/domain/HandlerMetadata.js +53 -0
- package/lib/esm/domain/HandlerMetadata.js.map +1 -0
- package/lib/esm/domain/PlatformContext.js +81 -0
- package/lib/esm/domain/PlatformContext.js.map +1 -0
- package/lib/esm/domain/PlatformRouteDetails.js +20 -0
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -0
- package/lib/esm/domain/PropertyMetadata.js +25 -0
- package/lib/esm/domain/PropertyMetadata.js.map +1 -0
- package/lib/esm/domain/index.js +8 -0
- package/lib/esm/domain/index.js.map +1 -0
- package/lib/esm/index.js +31 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/interfaces/AfterInit.js +2 -0
- package/lib/esm/interfaces/AfterInit.js.map +1 -0
- package/lib/esm/interfaces/AfterListen.js +2 -0
- package/lib/esm/interfaces/AfterListen.js.map +1 -0
- package/lib/esm/interfaces/AfterRoutesInit.js +2 -0
- package/lib/esm/interfaces/AfterRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeInit.js +2 -0
- package/lib/esm/interfaces/BeforeInit.js.map +1 -0
- package/lib/esm/interfaces/BeforeListen.js +2 -0
- package/lib/esm/interfaces/BeforeListen.js.map +1 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js +2 -0
- package/lib/esm/interfaces/BeforeRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/HandlerType.js +14 -0
- package/lib/esm/interfaces/HandlerType.js.map +1 -0
- package/lib/esm/interfaces/IncomingEvent.js +2 -0
- package/lib/esm/interfaces/IncomingEvent.js.map +1 -0
- package/lib/esm/interfaces/OnReady.js +2 -0
- package/lib/esm/interfaces/OnReady.js.map +1 -0
- package/lib/esm/interfaces/OnRequest.js +2 -0
- package/lib/esm/interfaces/OnRequest.js.map +1 -0
- package/lib/esm/interfaces/OnResponse.js +2 -0
- package/lib/esm/interfaces/OnResponse.js.map +1 -0
- package/lib/esm/interfaces/OnRoutesInit.js +2 -0
- package/lib/esm/interfaces/OnRoutesInit.js.map +1 -0
- package/lib/esm/interfaces/PathType.js +2 -0
- package/lib/esm/interfaces/PathType.js.map +1 -0
- package/lib/esm/interfaces/PlatformAdapter.js +2 -0
- package/lib/esm/interfaces/PlatformAdapter.js.map +1 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js +2 -0
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -0
- package/lib/esm/interfaces/ResponseErrorObject.js +2 -0
- package/lib/esm/interfaces/ResponseErrorObject.js.map +1 -0
- package/lib/esm/interfaces/Route.js +2 -0
- package/lib/esm/interfaces/Route.js.map +1 -0
- package/lib/esm/interfaces/index.js +18 -0
- package/lib/esm/interfaces/index.js.map +1 -0
- package/lib/esm/middlewares/AcceptMimesMiddleware.js +24 -0
- package/lib/esm/middlewares/AcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.js +23 -0
- package/lib/esm/middlewares/GlobalAcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +34 -0
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +52 -0
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js +9 -0
- package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +1 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js +9 -0
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -0
- package/lib/esm/middlewares/index.js +6 -0
- package/lib/esm/middlewares/index.js.map +1 -0
- package/lib/esm/services/FakeRawDriver.js +22 -0
- package/lib/esm/services/FakeRawDriver.js.map +1 -0
- package/lib/esm/services/Platform.js +104 -0
- package/lib/esm/services/Platform.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +31 -0
- package/lib/esm/services/PlatformApplication.js.map +1 -0
- package/lib/esm/services/PlatformHandler.js +232 -0
- package/lib/esm/services/PlatformHandler.js.map +1 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js +31 -0
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -0
- package/lib/esm/services/PlatformRequest.js +135 -0
- package/lib/esm/services/PlatformRequest.js.map +1 -0
- package/lib/esm/services/PlatformResponse.js +268 -0
- package/lib/esm/services/PlatformResponse.js.map +1 -0
- package/lib/esm/services/PlatformRouter.js +123 -0
- package/lib/esm/services/PlatformRouter.js.map +1 -0
- package/lib/esm/services/PlatformTest.js +163 -0
- package/lib/esm/services/PlatformTest.js.map +1 -0
- package/lib/esm/services/index.js +9 -0
- package/lib/esm/services/index.js.map +1 -0
- package/lib/esm/utils/createContext.js +34 -0
- package/lib/esm/utils/createContext.js.map +1 -0
- package/lib/esm/utils/createHandlerMetadata.js +45 -0
- package/lib/esm/utils/createHandlerMetadata.js.map +1 -0
- package/lib/esm/utils/createHttpServer.js +29 -0
- package/lib/esm/utils/createHttpServer.js.map +1 -0
- package/lib/esm/utils/createHttpsServer.js +29 -0
- package/lib/esm/utils/createHttpsServer.js.map +1 -0
- package/lib/esm/utils/createInjector.js +34 -0
- package/lib/esm/utils/createInjector.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +38 -0
- package/lib/esm/utils/getConfiguration.js.map +1 -0
- package/lib/esm/utils/getStaticsOptions.js +17 -0
- package/lib/esm/utils/getStaticsOptions.js.map +1 -0
- package/lib/esm/utils/index.js +9 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/listenServer.js +17 -0
- package/lib/esm/utils/listenServer.js.map +1 -0
- package/lib/esm/utils/loadInjector.js +10 -0
- package/lib/esm/utils/loadInjector.js.map +1 -0
- package/lib/esm/utils/mapReturnedResponse.js +11 -0
- package/lib/esm/utils/mapReturnedResponse.js.map +1 -0
- package/lib/esm/utils/printRoutes.js +32 -0
- package/lib/esm/utils/printRoutes.js.map +1 -0
- package/lib/esm/utils/setResponseHeaders.js +31 -0
- package/lib/esm/utils/setResponseHeaders.js.map +1 -0
- package/lib/esm/utils/useCtxHandler.js +11 -0
- package/lib/esm/utils/useCtxHandler.js.map +1 -0
- package/lib/types/PlatformModule.d.ts +6 -0
- package/lib/types/builder/PlatformBuilder.d.ts +104 -0
- package/lib/types/builder/PlatformControllerBuilder.d.ts +17 -0
- package/lib/types/config/index.d.ts +3 -0
- package/lib/types/config/interfaces/ConverterSettings.d.ts +6 -0
- package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +3 -0
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +44 -0
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +138 -0
- package/lib/types/config/interfaces/PlatformStaticsSettings.d.ts +17 -0
- package/lib/types/config/interfaces/index.d.ts +97 -0
- package/lib/types/config/services/PlatformConfiguration.d.ts +81 -0
- package/lib/types/constants/routerOptions.d.ts +1 -0
- package/lib/types/decorators/httpServer.d.ts +28 -0
- package/lib/types/decorators/httpsServer.d.ts +28 -0
- package/lib/types/decorators/index.d.ts +16 -0
- package/lib/types/decorators/method/acceptMime.d.ts +19 -0
- package/lib/types/decorators/method/endpointFn.d.ts +9 -0
- package/lib/types/decorators/method/location.d.ts +1 -0
- package/lib/types/decorators/method/redirect.d.ts +1 -0
- package/lib/types/decorators/method/route.d.ts +1 -0
- package/lib/types/decorators/method/view.d.ts +25 -0
- package/lib/types/decorators/multer/index.d.ts +3 -0
- package/lib/types/decorators/multer/multerFileSize.d.ts +27 -0
- package/lib/types/decorators/multer/multerOptions.d.ts +41 -0
- package/lib/types/decorators/multer/multipartFile.d.ts +47 -0
- package/lib/types/decorators/params/endpointInfo.d.ts +13 -0
- package/lib/types/decorators/params/error.d.ts +7 -0
- package/lib/types/decorators/params/next.d.ts +22 -0
- package/lib/types/decorators/params/request.d.ts +46 -0
- package/lib/types/decorators/params/response.d.ts +40 -0
- package/lib/types/decorators/params/responseData.d.ts +9 -0
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +18 -0
- package/lib/types/domain/ControllerProvider.d.ts +24 -0
- package/lib/types/domain/EndpointMetadata.d.ts +76 -0
- package/lib/types/domain/HandlerMetadata.d.ts +32 -0
- package/lib/types/domain/PlatformContext.d.ts +65 -0
- package/lib/types/domain/PlatformRouteDetails.d.ts +23 -0
- package/lib/types/domain/PropertyMetadata.d.ts +17 -0
- package/lib/types/domain/index.d.ts +7 -0
- package/lib/types/index.d.ts +22 -0
- package/lib/types/interfaces/AfterInit.d.ts +3 -0
- package/lib/types/interfaces/AfterListen.d.ts +3 -0
- package/lib/types/interfaces/AfterRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/BeforeInit.d.ts +3 -0
- package/lib/types/interfaces/BeforeListen.d.ts +3 -0
- package/lib/types/interfaces/BeforeRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/HandlerType.d.ts +12 -0
- package/lib/types/interfaces/IncomingEvent.d.ts +6 -0
- package/lib/types/interfaces/OnReady.d.ts +3 -0
- package/lib/types/interfaces/OnRequest.d.ts +4 -0
- package/lib/types/interfaces/OnResponse.d.ts +4 -0
- package/lib/types/interfaces/OnRoutesInit.d.ts +3 -0
- package/lib/types/interfaces/PathType.d.ts +1 -0
- package/lib/types/interfaces/PlatformAdapter.d.ts +19 -0
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +16 -0
- package/lib/types/interfaces/ResponseErrorObject.d.ts +8 -0
- package/lib/types/interfaces/Route.d.ts +10 -0
- package/lib/types/interfaces/index.d.ts +17 -0
- package/lib/types/middlewares/AcceptMimesMiddleware.d.ts +10 -0
- package/lib/types/middlewares/GlobalAcceptMimesMiddleware.d.ts +9 -0
- package/lib/types/middlewares/PlatformAcceptMimesMiddleware.d.ts +10 -0
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +19 -0
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +2 -0
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +5 -0
- package/lib/types/middlewares/index.d.ts +5 -0
- package/lib/types/services/FakeRawDriver.d.ts +15 -0
- package/lib/types/services/Platform.d.ts +37 -0
- package/lib/types/services/PlatformApplication.d.ts +21 -0
- package/lib/types/services/PlatformHandler.d.ts +80 -0
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -0
- package/lib/types/services/PlatformRequest.d.ts +112 -0
- package/lib/types/services/PlatformResponse.d.ts +161 -0
- package/lib/types/services/PlatformRouter.d.ts +48 -0
- package/lib/types/services/PlatformTest.d.ts +58 -0
- package/lib/types/services/index.d.ts +8 -0
- package/lib/types/utils/createContext.d.ts +9 -0
- package/lib/types/utils/createHandlerMetadata.d.ts +8 -0
- package/lib/types/utils/createHttpServer.d.ts +4 -0
- package/lib/types/utils/createHttpsServer.d.ts +4 -0
- package/lib/types/utils/createInjector.d.ts +7 -0
- package/lib/types/utils/getConfiguration.d.ts +2 -0
- package/lib/types/utils/getStaticsOptions.d.ts +5 -0
- package/lib/types/utils/index.d.ts +8 -0
- package/lib/types/utils/listenServer.d.ts +7 -0
- package/lib/types/utils/loadInjector.d.ts +6 -0
- package/lib/types/utils/mapReturnedResponse.d.ts +4 -0
- package/lib/types/utils/printRoutes.d.ts +2 -0
- package/lib/types/utils/setResponseHeaders.d.ts +5 -0
- package/lib/types/utils/useCtxHandler.d.ts +13 -0
- package/package.json +26 -23
- package/tsconfig.compile.esm.json +23 -0
- package/lib/index.js +0 -3634
- package/lib/index.js.map +0 -1
- package/lib/index.modern.js +0 -3448
- package/lib/index.modern.js.map +0 -1
- package/lib/utils/createHttpServer.d.ts +0 -3
- package/lib/utils/createHttpsServer.d.ts +0 -3
- package/lib/utils/listenServer.d.ts +0 -10
|
@@ -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"]}
|
|
File without changes
|
|
@@ -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, core_1.useMethodDecorators)((0, schema_1.Returns)(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), (0, schema_1.Consumes)("multipart/form-data"), (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,yCAA+C;AAE/C,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,0BAAmB,EACjB,IAAA,gBAAO,EAAC,GAAG,CAAC,CAAC,WAAW,CACtB,+KAA+K,CAChL,EACD,IAAA,iBAAQ,EAAC,qBAAqB,CAAC,EAC/B,IAAA,iBAAU,EAAC,mDAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CACjE,EACD,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;AA3BD,sCA2BC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, Returns} 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 useMethodDecorators(\n Returns(400).Description(\n `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`\n ),\n Consumes(\"multipart/form-data\"),\n StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))\n ),\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"]}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointInfo = void 0;
|
|
4
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
5
|
+
/**
|
|
6
|
+
* Get the current endpoint metadata.
|
|
7
|
+
* @decorator
|
|
8
|
+
* @operation
|
|
9
|
+
* @input
|
|
10
|
+
* @deprecated Use `@Context() $ctx: Context` then `$ctx.endpoint` instead.
|
|
11
|
+
*/
|
|
12
|
+
function EndpointInfo() {
|
|
13
|
+
return (0, platform_params_1.UseParam)({
|
|
14
|
+
paramType: platform_params_1.ParamTypes.$CTX,
|
|
15
|
+
dataPath: "$ctx.endpoint",
|
|
16
|
+
useConverter: false,
|
|
17
|
+
useValidation: false
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.EndpointInfo = EndpointInfo;
|
|
21
|
+
//# sourceMappingURL=endpointInfo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endpointInfo.js","sourceRoot":"","sources":["../../../../src/decorators/params/endpointInfo.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAG3D;;;;;;GAMG;AACH,SAAgB,YAAY;IAC1B,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,IAAI;QAC1B,QAAQ,EAAE,eAAe;QACzB,YAAY,EAAE,KAAK;QACnB,aAAa,EAAE,KAAK;KACrB,CAAC,CAAC;AACL,CAAC;AAPD,oCAOC","sourcesContent":["import {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {EndpointMetadata} from \"../../domain/EndpointMetadata\";\n\n/**\n * Get the current endpoint metadata.\n * @decorator\n * @operation\n * @input\n * @deprecated Use `@Context() $ctx: Context` then `$ctx.endpoint` instead.\n */\nexport function EndpointInfo(): Function {\n return UseParam({\n paramType: ParamTypes.$CTX,\n dataPath: \"$ctx.endpoint\",\n useConverter: false,\n useValidation: false\n });\n}\n/**\n * @deprecated\n */\nexport type EndpointInfo = EndpointMetadata;\n"]}
|
|
File without changes
|
|
@@ -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"]}
|
|
File without changes
|
|
@@ -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"]}
|
|
File without changes
|
|
@@ -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"]}
|
|
File without changes
|
|
@@ -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"]}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseData = void 0;
|
|
4
|
+
const platform_params_1 = require("@tsed/platform-params");
|
|
5
|
+
const platform_params_2 = require("@tsed/platform-params");
|
|
6
|
+
/**
|
|
7
|
+
* Return the current response data. Prefer the @@Context@@ decorator to get or set data.
|
|
8
|
+
*
|
|
9
|
+
* @decorator
|
|
10
|
+
* @operation
|
|
11
|
+
* @input
|
|
12
|
+
* @deprecated Use `@Context() $ctx: Context` then $ctx.data.
|
|
13
|
+
*/
|
|
14
|
+
function ResponseData() {
|
|
15
|
+
return (0, platform_params_2.UseParam)({
|
|
16
|
+
paramType: platform_params_1.ParamTypes.$CTX,
|
|
17
|
+
dataPath: "$ctx.data"
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
exports.ResponseData = ResponseData;
|
|
21
|
+
//# sourceMappingURL=responseData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseData.js","sourceRoot":"","sources":["../../../../src/decorators/params/responseData.ts"],"names":[],"mappings":";;;AAAA,2DAAiD;AACjD,2DAA+C;AAE/C;;;;;;;GAOG;AACH,SAAgB,YAAY;IAC1B,OAAO,IAAA,0BAAQ,EAAC;QACd,SAAS,EAAE,4BAAU,CAAC,IAAI;QAC1B,QAAQ,EAAE,WAAW;KACtB,CAAC,CAAC;AACL,CAAC;AALD,oCAKC","sourcesContent":["import {ParamTypes} from \"@tsed/platform-params\";\nimport {UseParam} from \"@tsed/platform-params\";\n\n/**\n * Return the current response data. Prefer the @@Context@@ decorator to get or set data.\n *\n * @decorator\n * @operation\n * @input\n * @deprecated Use `@Context() $ctx: Context` then $ctx.data.\n */\nexport function ResponseData(): ParameterDecorator {\n return UseParam({\n paramType: ParamTypes.$CTX,\n dataPath: \"$ctx.data\"\n });\n}\n"]}
|
|
File without changes
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
if (!($ctx === null || $ctx === void 0 ? void 0 : $ctx.isDone())) {
|
|
14
|
+
if (($ctx === null || $ctx === void 0 ? void 0 : $ctx.request.isAborted()) || ($ctx === null || $ctx === void 0 ? void 0 : $ctx.response.isDone())) {
|
|
15
|
+
this.destroy();
|
|
16
|
+
if (this.status === core_1.AnyToPromiseStatus.PENDING) {
|
|
17
|
+
this.status = core_1.AnyToPromiseStatus.RESOLVED;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return super.isDone();
|
|
22
|
+
}
|
|
23
|
+
async call(cb) {
|
|
24
|
+
return super.call(() => cb(this));
|
|
25
|
+
}
|
|
26
|
+
destroy() {
|
|
27
|
+
// @ts-ignore
|
|
28
|
+
delete this.$ctx;
|
|
29
|
+
}
|
|
30
|
+
isCanceledResponse(process) {
|
|
31
|
+
return process === this.$ctx.getResponse();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.AnyToPromiseWithCtx = AnyToPromiseWithCtx;
|
|
35
|
+
//# sourceMappingURL=AnyToPromiseWithCtx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA8E;AAW9E,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,IAAI,CAAC,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,EAAE,CAAA,EAAE;YACnB,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC,SAAS,EAAE,MAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,CAAC,MAAM,EAAE,CAAA,EAAE;gBACxD,IAAI,CAAC,OAAO,EAAE,CAAC;gBAEf,IAAI,IAAI,CAAC,MAAM,KAAK,yBAAkB,CAAC,OAAO,EAAE;oBAC9C,IAAI,CAAC,MAAM,GAAG,yBAAkB,CAAC,QAAQ,CAAC;iBAC3C;aACF;SACF;QAED,OAAO,KAAK,CAAC,MAAM,EAAE,CAAC;IACxB,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;AAtCD,kDAsCC","sourcesContent":["import {AnyPromiseResult, AnyToPromise, AnyToPromiseStatus} 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 if (!$ctx?.isDone()) {\n if ($ctx?.request.isAborted() || $ctx?.response.isDone()) {\n this.destroy();\n\n if (this.status === AnyToPromiseStatus.PENDING) {\n this.status = AnyToPromiseStatus.RESOLVED;\n }\n }\n }\n\n return 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"]}
|
|
File without changes
|
|
@@ -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"]}
|
|
File without changes
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EndpointMetadata = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const core_1 = require("@tsed/core");
|
|
6
|
+
const schema_1 = require("@tsed/schema");
|
|
7
|
+
/**
|
|
8
|
+
* EndpointMetadata contains metadata about a controller and his method.
|
|
9
|
+
* Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.
|
|
10
|
+
* EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.
|
|
11
|
+
*
|
|
12
|
+
* Example :
|
|
13
|
+
*
|
|
14
|
+
* @Controller("/my-path")
|
|
15
|
+
* provide MyClass {
|
|
16
|
+
*
|
|
17
|
+
* @Get("/")
|
|
18
|
+
* @Authenticated()
|
|
19
|
+
* public myMethod(){}
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
let EndpointMetadata = class EndpointMetadata extends schema_1.JsonMethodStore {
|
|
24
|
+
constructor(options) {
|
|
25
|
+
super({
|
|
26
|
+
store: core_1.Store.fromMethod(options.target, options.propertyKey),
|
|
27
|
+
descriptor: (0, core_1.descriptorOf)(options.target, options.propertyKey),
|
|
28
|
+
...options
|
|
29
|
+
});
|
|
30
|
+
this.beforeMiddlewares = [];
|
|
31
|
+
this.middlewares = [];
|
|
32
|
+
this.afterMiddlewares = [];
|
|
33
|
+
const { beforeMiddlewares = [], middlewares = [], afterMiddlewares = [] } = options;
|
|
34
|
+
this.after(afterMiddlewares);
|
|
35
|
+
this.before(beforeMiddlewares);
|
|
36
|
+
this.use(middlewares);
|
|
37
|
+
}
|
|
38
|
+
get targetName() {
|
|
39
|
+
return (0, core_1.nameOf)(this.token);
|
|
40
|
+
}
|
|
41
|
+
get params() {
|
|
42
|
+
return this.parameters;
|
|
43
|
+
}
|
|
44
|
+
get view() {
|
|
45
|
+
return this.store.get("view");
|
|
46
|
+
}
|
|
47
|
+
set view(view) {
|
|
48
|
+
this.store.set("view", view);
|
|
49
|
+
}
|
|
50
|
+
get acceptMimes() {
|
|
51
|
+
return this.store.get("acceptMimes", []);
|
|
52
|
+
}
|
|
53
|
+
set acceptMimes(mimes) {
|
|
54
|
+
this.store.set("acceptMimes", mimes);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get an endpoint.
|
|
58
|
+
* @param target
|
|
59
|
+
* @param propertyKey
|
|
60
|
+
* @param descriptor
|
|
61
|
+
*/
|
|
62
|
+
static get(target, propertyKey, descriptor) {
|
|
63
|
+
descriptor = descriptor || (0, core_1.descriptorOf)((0, core_1.prototypeOf)(target), propertyKey);
|
|
64
|
+
return schema_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey, descriptor);
|
|
65
|
+
}
|
|
66
|
+
addOperationPath(method, path, options = {}) {
|
|
67
|
+
return this.operation.addOperationPath(method, path, options);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
|
|
71
|
+
*
|
|
72
|
+
* @param key
|
|
73
|
+
* @returns {any}
|
|
74
|
+
*/
|
|
75
|
+
get(key) {
|
|
76
|
+
const ctrlValue = core_1.Store.from(this.target).get(key);
|
|
77
|
+
return (0, core_1.deepMerge)(ctrlValue, this.store.get(key));
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Append middlewares to the beforeMiddlewares list.
|
|
81
|
+
* @param args
|
|
82
|
+
* @returns {EndpointMetadata}
|
|
83
|
+
*/
|
|
84
|
+
before(args) {
|
|
85
|
+
this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(core_1.isFunction);
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Append middlewares to the afterMiddlewares list.
|
|
90
|
+
* @param args
|
|
91
|
+
* @returns {EndpointMetadata}
|
|
92
|
+
*/
|
|
93
|
+
after(args) {
|
|
94
|
+
this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(core_1.isFunction);
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Store all arguments collected via Annotation.
|
|
99
|
+
* @param args
|
|
100
|
+
*/
|
|
101
|
+
use(args) {
|
|
102
|
+
this.middlewares = this.middlewares.concat(args).filter(core_1.isFunction);
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
EndpointMetadata = (0, tslib_1.__decorate)([
|
|
107
|
+
(0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.METHOD),
|
|
108
|
+
(0, tslib_1.__metadata)("design:paramtypes", [Object])
|
|
109
|
+
], EndpointMetadata);
|
|
110
|
+
exports.EndpointMetadata = EndpointMetadata;
|
|
111
|
+
//# sourceMappingURL=EndpointMetadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;;AAAA,qCAAiH;AAEjH,yCAA0H;AAkB1H;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,wBAAe;IAKnD,YAAY,OAAmC;QAC7C,KAAK,CAAC;YACJ,KAAK,EAAE,YAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC7D,UAAU,EAAE,IAAA,mBAAY,EAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC9D,GAAG,OAAO;SACX,CAAC,CAAC;QATE,sBAAiB,GAAU,EAAE,CAAC;QAC9B,gBAAW,GAAU,EAAE,CAAC;QACxB,qBAAgB,GAAU,EAAE,CAAC;QASlC,MAAM,EAAC,iBAAiB,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAC,GAAG,OAAO,CAAC;QAElF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAwB,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,IAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAW,aAAa,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,WAAW,CAAC,KAAe;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAA+B;QACzF,UAAU,GAAG,UAAU,IAAI,IAAA,mBAAY,EAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;QAE1E,OAAO,wBAAe,CAAC,IAAI,CAAmB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,IAAqB,EAAE,UAAe,EAAE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,GAAQ;QACnB,MAAM,SAAS,GAAG,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnD,OAAO,IAAA,gBAAS,EAAI,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,IAAgB;QAC5B,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAEhF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAgB;QAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,IAAgB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAEpE,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtGY,gBAAgB;IAD5B,IAAA,4BAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;;GAC9B,gBAAgB,CAsG5B;AAtGY,4CAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isFunction, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonEntityStoreOptions, JsonMethodStore, JsonOperation} from \"@tsed/schema\";\n\nexport interface EndpointConstructorOptions extends JsonEntityStoreOptions {\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n}\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore implements EndpointConstructorOptions {\n public beforeMiddlewares: any[] = [];\n public middlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n\n constructor(options: EndpointConstructorOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n}\n"]}
|
|
File without changes
|