@tsed/common 7.0.0-beta.2 → 7.0.0-beta.20
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/coverage.json +6 -0
- package/jest.config.js +9 -0
- package/lib/cjs/builder/PlatformBuilder.js +94 -65
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +2 -66
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/cjs/decorators/multer/multipartFile.js.map +1 -1
- package/lib/cjs/decorators/params/error.js +1 -1
- package/lib/cjs/decorators/params/error.js.map +1 -1
- package/lib/cjs/domain/AnyToPromiseWithCtx.js +4 -5
- package/lib/cjs/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/cjs/domain/EndpointMetadata.js +2 -66
- package/lib/cjs/domain/EndpointMetadata.js.map +1 -1
- package/lib/cjs/domain/PlatformContext.js +46 -38
- package/lib/cjs/domain/PlatformContext.js.map +1 -1
- package/lib/cjs/domain/PlatformRouteDetails.js +0 -21
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/cjs/exports.js +32 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +58 -30
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/cjs/interfaces/Route.js.map +1 -1
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +10 -9
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +27 -13
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FakeAdapter.js +49 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +33 -68
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +24 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +26 -14
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformHandler.js +115 -172
- package/lib/cjs/services/PlatformHandler.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +46 -19
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +17 -13
- package/lib/cjs/services/PlatformRequest.js.map +1 -1
- package/lib/cjs/services/PlatformResponse.js +20 -23
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +31 -10
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/createContext.js +32 -21
- package/lib/cjs/utils/createContext.js.map +1 -1
- package/lib/cjs/utils/createHttpServer.js +6 -11
- package/lib/cjs/utils/createHttpServer.js.map +1 -1
- package/lib/cjs/utils/createHttpsServer.js +6 -11
- package/lib/cjs/utils/createHttpsServer.js.map +1 -1
- package/lib/cjs/utils/createInjector.js +16 -10
- package/lib/cjs/utils/createInjector.js.map +1 -1
- package/lib/cjs/utils/ensureContext.js +16 -0
- package/lib/cjs/utils/ensureContext.js.map +1 -0
- package/lib/cjs/utils/getConfiguration.js +6 -12
- package/lib/cjs/utils/getConfiguration.js.map +1 -1
- package/lib/cjs/utils/printRoutes.js +10 -8
- package/lib/cjs/utils/printRoutes.js.map +1 -1
- package/lib/cjs/utils/setResponseHeaders.js +8 -14
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
- package/lib/esm/builder/PlatformBuilder.js +74 -68
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformLoggerSettings.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -1
- package/lib/esm/config/services/PlatformConfiguration.js +0 -64
- package/lib/esm/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/esm/decorators/multer/multerFileSize.js +1 -1
- package/lib/esm/decorators/multer/multerOptions.js +1 -1
- package/lib/esm/decorators/multer/multipartFile.js +1 -1
- package/lib/esm/decorators/multer/multipartFile.js.map +1 -1
- package/lib/esm/decorators/params/error.js +1 -1
- package/lib/esm/decorators/params/error.js.map +1 -1
- package/lib/esm/domain/AnyToPromiseWithCtx.js +4 -5
- package/lib/esm/domain/AnyToPromiseWithCtx.js.map +1 -1
- package/lib/esm/domain/EndpointMetadata.js +1 -66
- package/lib/esm/domain/EndpointMetadata.js.map +1 -1
- package/lib/esm/domain/PlatformContext.js +49 -41
- package/lib/esm/domain/PlatformContext.js.map +1 -1
- package/lib/esm/domain/PlatformRouteDetails.js +1 -19
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/esm/exports.js +14 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +58 -27
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/esm/interfaces/Route.js.map +1 -1
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js +2 -1
- package/lib/esm/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +18 -5
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FakeAdapter.js +45 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +34 -69
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +20 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +27 -15
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformHandler.js +116 -173
- package/lib/esm/services/PlatformHandler.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +49 -22
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/services/PlatformRequest.js +16 -12
- package/lib/esm/services/PlatformRequest.js.map +1 -1
- package/lib/esm/services/PlatformResponse.js +19 -22
- package/lib/esm/services/PlatformResponse.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +34 -14
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/createContext.js +33 -23
- package/lib/esm/utils/createContext.js.map +1 -1
- package/lib/esm/utils/createHttpServer.js +6 -11
- package/lib/esm/utils/createHttpServer.js.map +1 -1
- package/lib/esm/utils/createHttpsServer.js +6 -11
- package/lib/esm/utils/createHttpsServer.js.map +1 -1
- package/lib/esm/utils/createInjector.js +20 -14
- package/lib/esm/utils/createInjector.js.map +1 -1
- package/lib/esm/utils/ensureContext.js +12 -0
- package/lib/esm/utils/ensureContext.js.map +1 -0
- package/lib/esm/utils/getConfiguration.js +8 -14
- package/lib/esm/utils/getConfiguration.js.map +1 -1
- package/lib/esm/utils/printRoutes.js +10 -8
- package/lib/esm/utils/printRoutes.js.map +1 -1
- package/lib/esm/utils/setResponseHeaders.js +8 -14
- package/lib/esm/utils/setResponseHeaders.js.map +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +19 -17
- package/lib/types/config/interfaces/PlatformLoggerSettings.d.ts +2 -43
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
- package/lib/types/config/services/PlatformConfiguration.d.ts +6 -21
- package/lib/types/domain/AnyToPromiseWithCtx.d.ts +1 -9
- package/lib/types/domain/EndpointMetadata.d.ts +1 -50
- package/lib/types/domain/PlatformContext.d.ts +32 -18
- package/lib/types/domain/PlatformRouteDetails.d.ts +4 -20
- package/lib/types/exports.d.ts +13 -0
- package/lib/types/index.d.ts +56 -18
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -2
- package/lib/types/interfaces/Route.d.ts +2 -3
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
- package/lib/types/services/FakeAdapter.d.ts +31 -0
- package/lib/types/services/Platform.d.ts +9 -21
- package/lib/types/services/PlatformAdapter.d.ts +58 -0
- package/lib/types/services/PlatformApplication.d.ts +15 -7
- package/lib/types/services/PlatformHandler.d.ts +21 -59
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -3
- package/lib/types/services/PlatformRequest.d.ts +8 -10
- package/lib/types/services/PlatformResponse.d.ts +15 -19
- package/lib/types/services/PlatformTest.d.ts +5 -4
- package/lib/types/utils/createContext.d.ts +4 -1
- package/lib/types/utils/createHttpServer.d.ts +1 -1
- package/lib/types/utils/createHttpsServer.d.ts +3 -1
- package/lib/types/utils/createInjector.d.ts +5 -3
- package/lib/types/utils/ensureContext.d.ts +2 -0
- package/lib/types/utils/listenServer.d.ts +2 -0
- package/package.json +43 -26
- package/readme.md +52 -58
- package/tsconfig.compile.esm.json +2 -12
- package/lib/cjs/builder/PlatformControllerBuilder.js +0 -85
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/cjs/config/index.js +0 -7
- package/lib/cjs/config/index.js.map +0 -1
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js +0 -3
- package/lib/cjs/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
- package/lib/cjs/config/interfaces/index.js +0 -8
- package/lib/cjs/config/interfaces/index.js.map +0 -1
- package/lib/cjs/decorators/httpServer.js +0 -32
- package/lib/cjs/decorators/httpServer.js.map +0 -1
- package/lib/cjs/decorators/httpsServer.js +0 -32
- package/lib/cjs/decorators/httpsServer.js.map +0 -1
- package/lib/cjs/decorators/index.js +0 -21
- package/lib/cjs/decorators/index.js.map +0 -1
- package/lib/cjs/decorators/method/acceptMime.js +0 -28
- package/lib/cjs/decorators/method/acceptMime.js.map +0 -1
- package/lib/cjs/decorators/method/endpointFn.js +0 -15
- package/lib/cjs/decorators/method/endpointFn.js.map +0 -1
- package/lib/cjs/decorators/method/location.js +0 -6
- package/lib/cjs/decorators/method/location.js.map +0 -1
- package/lib/cjs/decorators/method/redirect.js +0 -6
- package/lib/cjs/decorators/method/redirect.js.map +0 -1
- package/lib/cjs/decorators/method/route.js +0 -13
- package/lib/cjs/decorators/method/route.js.map +0 -1
- package/lib/cjs/decorators/method/view.js +0 -34
- package/lib/cjs/decorators/method/view.js.map +0 -1
- package/lib/cjs/decorators/multer/index.js +0 -7
- package/lib/cjs/decorators/multer/index.js.map +0 -1
- package/lib/cjs/domain/ControllerProvider.js +0 -51
- package/lib/cjs/domain/ControllerProvider.js.map +0 -1
- package/lib/cjs/domain/HandlerMetadata.js +0 -57
- package/lib/cjs/domain/HandlerMetadata.js.map +0 -1
- package/lib/cjs/domain/index.js +0 -10
- package/lib/cjs/domain/index.js.map +0 -1
- package/lib/cjs/interfaces/PathType.js +0 -3
- package/lib/cjs/interfaces/PathType.js.map +0 -1
- package/lib/cjs/interfaces/PlatformAdapter.js +0 -3
- package/lib/cjs/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/cjs/interfaces/index.js +0 -21
- package/lib/cjs/interfaces/index.js.map +0 -1
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +0 -12
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js.map +0 -1
- package/lib/cjs/middlewares/bindEndpointMiddleware.js +0 -13
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +0 -1
- package/lib/cjs/middlewares/index.js +0 -7
- package/lib/cjs/middlewares/index.js.map +0 -1
- package/lib/cjs/services/FakeRawDriver.js +0 -26
- package/lib/cjs/services/FakeRawDriver.js.map +0 -1
- package/lib/cjs/services/PlatformRouter.js +0 -126
- package/lib/cjs/services/PlatformRouter.js.map +0 -1
- package/lib/cjs/services/index.js +0 -12
- package/lib/cjs/services/index.js.map +0 -1
- package/lib/cjs/utils/createHandlerMetadata.js +0 -49
- package/lib/cjs/utils/createHandlerMetadata.js.map +0 -1
- package/lib/cjs/utils/index.js +0 -11
- package/lib/cjs/utils/index.js.map +0 -1
- package/lib/cjs/utils/useCtxHandler.js +0 -15
- package/lib/cjs/utils/useCtxHandler.js.map +0 -1
- package/lib/esm/builder/PlatformControllerBuilder.js +0 -79
- package/lib/esm/builder/PlatformControllerBuilder.js.map +0 -1
- package/lib/esm/config/index.js +0 -4
- package/lib/esm/config/index.js.map +0 -1
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js +0 -2
- package/lib/esm/config/interfaces/EndpointDirectoriesSettings.js.map +0 -1
- package/lib/esm/config/interfaces/index.js +0 -5
- package/lib/esm/config/interfaces/index.js.map +0 -1
- package/lib/esm/decorators/httpServer.js +0 -28
- package/lib/esm/decorators/httpServer.js.map +0 -1
- package/lib/esm/decorators/httpsServer.js +0 -28
- package/lib/esm/decorators/httpsServer.js.map +0 -1
- package/lib/esm/decorators/index.js +0 -18
- package/lib/esm/decorators/index.js.map +0 -1
- package/lib/esm/decorators/method/acceptMime.js +0 -24
- package/lib/esm/decorators/method/acceptMime.js.map +0 -1
- package/lib/esm/decorators/method/endpointFn.js +0 -11
- package/lib/esm/decorators/method/endpointFn.js.map +0 -1
- package/lib/esm/decorators/method/location.js +0 -2
- package/lib/esm/decorators/method/location.js.map +0 -1
- package/lib/esm/decorators/method/redirect.js +0 -2
- package/lib/esm/decorators/method/redirect.js.map +0 -1
- package/lib/esm/decorators/method/route.js +0 -2
- package/lib/esm/decorators/method/route.js.map +0 -1
- package/lib/esm/decorators/method/view.js +0 -30
- package/lib/esm/decorators/method/view.js.map +0 -1
- package/lib/esm/decorators/multer/index.js +0 -4
- package/lib/esm/decorators/multer/index.js.map +0 -1
- package/lib/esm/domain/ControllerProvider.js +0 -47
- package/lib/esm/domain/ControllerProvider.js.map +0 -1
- package/lib/esm/domain/HandlerMetadata.js +0 -53
- package/lib/esm/domain/HandlerMetadata.js.map +0 -1
- package/lib/esm/domain/index.js +0 -7
- package/lib/esm/domain/index.js.map +0 -1
- package/lib/esm/interfaces/PathType.js +0 -2
- package/lib/esm/interfaces/PathType.js.map +0 -1
- package/lib/esm/interfaces/PlatformAdapter.js +0 -2
- package/lib/esm/interfaces/PlatformAdapter.js.map +0 -1
- package/lib/esm/interfaces/index.js +0 -18
- package/lib/esm/interfaces/index.js.map +0 -1
- package/lib/esm/middlewares/__mock__/FakeCtrl.js +0 -9
- package/lib/esm/middlewares/__mock__/FakeCtrl.js.map +0 -1
- package/lib/esm/middlewares/bindEndpointMiddleware.js +0 -9
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +0 -1
- package/lib/esm/middlewares/index.js +0 -4
- package/lib/esm/middlewares/index.js.map +0 -1
- package/lib/esm/services/FakeRawDriver.js +0 -22
- package/lib/esm/services/FakeRawDriver.js.map +0 -1
- package/lib/esm/services/PlatformRouter.js +0 -123
- package/lib/esm/services/PlatformRouter.js.map +0 -1
- package/lib/esm/services/index.js +0 -9
- package/lib/esm/services/index.js.map +0 -1
- package/lib/esm/utils/createHandlerMetadata.js +0 -45
- package/lib/esm/utils/createHandlerMetadata.js.map +0 -1
- package/lib/esm/utils/index.js +0 -8
- package/lib/esm/utils/index.js.map +0 -1
- package/lib/esm/utils/useCtxHandler.js +0 -11
- package/lib/esm/utils/useCtxHandler.js.map +0 -1
- package/lib/types/builder/PlatformControllerBuilder.d.ts +0 -17
- package/lib/types/config/index.d.ts +0 -3
- package/lib/types/config/interfaces/EndpointDirectoriesSettings.d.ts +0 -3
- package/lib/types/config/interfaces/index.d.ts +0 -97
- package/lib/types/decorators/httpServer.d.ts +0 -28
- package/lib/types/decorators/httpsServer.d.ts +0 -28
- package/lib/types/decorators/index.d.ts +0 -14
- package/lib/types/decorators/method/acceptMime.d.ts +0 -19
- package/lib/types/decorators/method/endpointFn.d.ts +0 -9
- package/lib/types/decorators/method/location.d.ts +0 -1
- package/lib/types/decorators/method/redirect.d.ts +0 -1
- package/lib/types/decorators/method/route.d.ts +0 -1
- package/lib/types/decorators/method/view.d.ts +0 -25
- package/lib/types/decorators/multer/index.d.ts +0 -3
- package/lib/types/domain/ControllerProvider.d.ts +0 -24
- package/lib/types/domain/HandlerMetadata.d.ts +0 -32
- package/lib/types/domain/index.d.ts +0 -6
- package/lib/types/interfaces/PathType.d.ts +0 -1
- package/lib/types/interfaces/PlatformAdapter.d.ts +0 -19
- package/lib/types/interfaces/index.d.ts +0 -17
- package/lib/types/middlewares/__mock__/FakeCtrl.d.ts +0 -2
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +0 -5
- package/lib/types/middlewares/index.d.ts +0 -3
- package/lib/types/services/FakeRawDriver.d.ts +0 -15
- package/lib/types/services/PlatformRouter.d.ts +0 -48
- package/lib/types/services/index.d.ts +0 -8
- package/lib/types/utils/createHandlerMetadata.d.ts +0 -8
- package/lib/types/utils/index.d.ts +0 -7
- package/lib/types/utils/useCtxHandler.d.ts +0 -13
|
@@ -3,21 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.AnyToPromiseWithCtx = void 0;
|
|
4
4
|
const core_1 = require("@tsed/core");
|
|
5
5
|
class AnyToPromiseWithCtx extends core_1.AnyToPromise {
|
|
6
|
-
|
|
6
|
+
$ctx;
|
|
7
|
+
constructor($ctx) {
|
|
7
8
|
super();
|
|
8
9
|
this.$ctx = $ctx;
|
|
9
|
-
this.err = err;
|
|
10
10
|
}
|
|
11
11
|
isDone() {
|
|
12
12
|
const { $ctx } = this;
|
|
13
|
-
return
|
|
13
|
+
return $ctx?.isDone() || super.isDone();
|
|
14
14
|
}
|
|
15
15
|
async call(cb) {
|
|
16
16
|
return super.call(() => cb(this));
|
|
17
17
|
}
|
|
18
18
|
destroy() {
|
|
19
|
-
|
|
20
|
-
delete this.$ctx;
|
|
19
|
+
this.$ctx = null;
|
|
21
20
|
}
|
|
22
21
|
isCanceledResponse(process) {
|
|
23
22
|
return process === this.$ctx.getResponse();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA0D;
|
|
1
|
+
{"version":3,"file":"AnyToPromiseWithCtx.js","sourceRoot":"","sources":["../../../src/domain/AnyToPromiseWithCtx.ts"],"names":[],"mappings":";;;AAAA,qCAA0D;AAG1D,MAAa,mBAAoB,SAAQ,mBAAY;IAC5C,IAAI,CAAkB;IAE7B,YAAY,IAAqB;QAC/B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,MAAM,EAAC,IAAI,EAAC,GAAG,IAAI,CAAC;QAEpB,OAAO,IAAI,EAAE,MAAM,EAAE,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;IAC1C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAY;QACrB,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,CAAC;IAED,OAAO;QACJ,IAAI,CAAC,IAAY,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,kBAAkB,CAAC,OAAY;QAC7B,OAAO,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;IAC7C,CAAC;CACF;AAzBD,kDAyBC","sourcesContent":["import {AnyPromiseResult, AnyToPromise} from \"@tsed/core\";\nimport {PlatformContext} from \"./PlatformContext\";\n\nexport class AnyToPromiseWithCtx extends AnyToPromise {\n public $ctx: PlatformContext;\n\n constructor($ctx: PlatformContext) {\n super();\n this.$ctx = $ctx;\n }\n\n isDone(): boolean {\n const {$ctx} = this;\n\n return $ctx?.isDone() || super.isDone();\n }\n\n async call(cb: Function): Promise<AnyPromiseResult<any>> {\n return super.call(() => cb(this));\n }\n\n destroy() {\n (this.$ctx as any) = null;\n }\n\n isCanceledResponse(process: any) {\n return process === this.$ctx.getResponse();\n }\n}\n"]}
|
|
@@ -1,70 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EndpointMetadata = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
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
|
-
get targetName() {
|
|
25
|
-
return (0, core_1.nameOf)(this.token);
|
|
26
|
-
}
|
|
27
|
-
get params() {
|
|
28
|
-
return this.parameters;
|
|
29
|
-
}
|
|
30
|
-
get view() {
|
|
31
|
-
return this.store.get("view");
|
|
32
|
-
}
|
|
33
|
-
set view(view) {
|
|
34
|
-
this.store.set("view", view);
|
|
35
|
-
}
|
|
36
|
-
get acceptMimes() {
|
|
37
|
-
return this.store.get("acceptMimes", []);
|
|
38
|
-
}
|
|
39
|
-
set acceptMimes(mimes) {
|
|
40
|
-
this.store.set("acceptMimes", mimes);
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get an endpoint.
|
|
44
|
-
* @param target
|
|
45
|
-
* @param propertyKey
|
|
46
|
-
* @param descriptor
|
|
47
|
-
*/
|
|
48
|
-
static get(target, propertyKey, descriptor) {
|
|
49
|
-
descriptor = descriptor || (0, core_1.descriptorOf)((0, core_1.prototypeOf)(target), propertyKey);
|
|
50
|
-
return schema_1.JsonEntityStore.from((0, core_1.prototypeOf)(target), propertyKey, descriptor);
|
|
51
|
-
}
|
|
52
|
-
addOperationPath(method, path, options = {}) {
|
|
53
|
-
return this.operation.addOperationPath(method, path, options);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
|
|
57
|
-
*
|
|
58
|
-
* @param key
|
|
59
|
-
* @returns {any}
|
|
60
|
-
*/
|
|
61
|
-
get(key) {
|
|
62
|
-
const ctrlValue = core_1.Store.from(this.target).get(key);
|
|
63
|
-
return (0, core_1.deepMerge)(ctrlValue, this.store.get(key));
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
EndpointMetadata = (0, tslib_1.__decorate)([
|
|
67
|
-
(0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.METHOD)
|
|
68
|
-
], EndpointMetadata);
|
|
69
|
-
exports.EndpointMetadata = EndpointMetadata;
|
|
4
|
+
var schema_1 = require("@tsed/schema");
|
|
5
|
+
Object.defineProperty(exports, "EndpointMetadata", { enumerable: true, get: function () { return schema_1.EndpointMetadata; } });
|
|
70
6
|
//# sourceMappingURL=EndpointMetadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;AAAA,uCAA8C;AAAtC,0GAAA,gBAAgB,OAAA","sourcesContent":["export {EndpointMetadata} from \"@tsed/schema\";\n"]}
|
|
@@ -6,26 +6,44 @@ const PlatformApplication_1 = require("../services/PlatformApplication");
|
|
|
6
6
|
const PlatformRequest_1 = require("../services/PlatformRequest");
|
|
7
7
|
const PlatformResponse_1 = require("../services/PlatformResponse");
|
|
8
8
|
class PlatformContext extends di_1.DIContext {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
9
|
+
event;
|
|
10
|
+
/**
|
|
11
|
+
* The data return by the previous endpoint if you use multiple handler on the same route. By default data is empty.
|
|
12
|
+
*/
|
|
13
|
+
data;
|
|
14
|
+
/**
|
|
15
|
+
* The error caught by the current handler
|
|
16
|
+
*/
|
|
17
|
+
error;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
next;
|
|
22
|
+
/**
|
|
23
|
+
* The current @@PlatformResponse@@.
|
|
24
|
+
*/
|
|
25
|
+
response;
|
|
26
|
+
/**
|
|
27
|
+
* The current @@PlatformRequest@@.
|
|
28
|
+
*/
|
|
29
|
+
request;
|
|
30
|
+
/**
|
|
31
|
+
* The current @@EndpointMetadata@@ resolved by Ts.ED during the request.
|
|
32
|
+
*/
|
|
33
|
+
endpoint;
|
|
34
|
+
/**
|
|
35
|
+
* The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.
|
|
36
|
+
*/
|
|
37
|
+
handlerMetadata;
|
|
38
|
+
#isFinished = false;
|
|
39
|
+
constructor(options) {
|
|
40
|
+
super(options);
|
|
41
|
+
options.endpoint && (this.endpoint = options.endpoint);
|
|
42
|
+
this.event = options.event;
|
|
43
|
+
this.response = new (options.ResponseKlass || PlatformResponse_1.PlatformResponse)(this);
|
|
44
|
+
this.request = new (options.RequestKlass || PlatformRequest_1.PlatformRequest)(this);
|
|
23
45
|
this.request.request.$ctx = this;
|
|
24
46
|
this.request.request.id = this.id;
|
|
25
|
-
this.logger.url = this.url;
|
|
26
|
-
this.container.set(PlatformResponse_1.PlatformResponse, this.response);
|
|
27
|
-
this.container.set(PlatformRequest_1.PlatformRequest, this.request);
|
|
28
|
-
this.container.set(PlatformContext, this);
|
|
29
47
|
this.response.setHeader("x-request-id", this.id);
|
|
30
48
|
}
|
|
31
49
|
get url() {
|
|
@@ -34,28 +52,18 @@ class PlatformContext extends di_1.DIContext {
|
|
|
34
52
|
get app() {
|
|
35
53
|
return this.injector.get(PlatformApplication_1.PlatformApplication);
|
|
36
54
|
}
|
|
37
|
-
async
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
this.
|
|
42
|
-
this
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
delete this.response;
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
delete this.request;
|
|
55
|
+
async start() {
|
|
56
|
+
return this.emit("$onRequest", this);
|
|
57
|
+
}
|
|
58
|
+
async finish() {
|
|
59
|
+
await Promise.all([this.emit("$onResponse", this), this.destroy()]);
|
|
60
|
+
this.#isFinished = true;
|
|
61
|
+
}
|
|
62
|
+
isFinished() {
|
|
63
|
+
return this.#isFinished;
|
|
49
64
|
}
|
|
50
65
|
isDone() {
|
|
51
|
-
|
|
52
|
-
if (!this.request || !this.response) {
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
if ((_a = this.request) === null || _a === void 0 ? void 0 : _a.isAborted()) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return (_b = this.response) === null || _b === void 0 ? void 0 : _b.isDone();
|
|
66
|
+
return this.request?.isAborted() || this.response?.isDone() || this.isFinished();
|
|
59
67
|
}
|
|
60
68
|
/**
|
|
61
69
|
* Return the framework request instance (Express, Koa, etc...)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"PlatformContext.js","sourceRoot":"","sources":["../../../src/domain/PlatformContext.ts"],"names":[],"mappings":";;;AAAA,iCAAqD;AAKrD,yEAAoE;AACpE,iEAA4D;AAC5D,mEAA8D;AAc9D,MAAa,eAGX,SAAQ,cAAS;IACV,KAAK,CAAgB;IAC5B;;OAEG;IACI,IAAI,CAAM;IACjB;;OAEG;IACI,KAAK,CAAW;IACvB;;OAEG;IACI,IAAI,CAAO;IAClB;;OAEG;IACM,QAAQ,CAAO;IACxB;;OAEG;IACM,OAAO,CAAO;IACvB;;OAEG;IACH,QAAQ,CAAmB;IAC3B;;OAEG;IACH,eAAe,CAA0B;IAEzC,WAAW,GAAY,KAAK,CAAC;IAE7B,YAAY,OAA+B;QACzC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,OAAO,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;QAEvD,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,IAAI,mCAAgB,CAAC,CAAC,IAAI,CAAC,CAAC;QACtE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,iCAAe,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnE,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAElC,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,yCAAmB,CAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,KAAK;QACT,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,CAAC,MAAM;QACV,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACpE,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;IACnF,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;AA9GD,0CA8GC","sourcesContent":["import {DIContext, DIContextOptions} from \"@tsed/di\";\nimport {PlatformHandlerMetadata} from \"@tsed/platform-router\";\nimport {EndpointMetadata} from \"@tsed/schema\";\nimport {IncomingMessage, ServerResponse} from \"http\";\nimport {IncomingEvent} from \"../interfaces/IncomingEvent\";\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: IncomingEvent;\n ignoreUrlPatterns?: any[];\n endpoint?: EndpointMetadata;\n}\n\nexport class PlatformContext<\n PReq extends PlatformRequest = PlatformRequest,\n PRes extends PlatformResponse = PlatformResponse\n> extends DIContext {\n public event: IncomingEvent;\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 error caught by the current handler\n */\n public error?: unknown;\n /**\n *\n */\n public next?: any;\n /**\n * The current @@PlatformResponse@@.\n */\n readonly response: PRes;\n /**\n * The current @@PlatformRequest@@.\n */\n readonly request: PReq;\n /**\n * The current @@EndpointMetadata@@ resolved by Ts.ED during the request.\n */\n endpoint: EndpointMetadata;\n /**\n * The current @@PlatformHandlerMetadata@@ resolved by Ts.ED during the request.\n */\n handlerMetadata: PlatformHandlerMetadata;\n\n #isFinished: boolean = false;\n\n constructor(options: PlatformContextOptions) {\n super(options);\n\n options.endpoint && (this.endpoint = options.endpoint);\n\n this.event = options.event;\n this.response = new (options.ResponseKlass || PlatformResponse)(this);\n this.request = new (options.RequestKlass || PlatformRequest)(this);\n\n this.request.request.$ctx = this;\n this.request.request.id = this.id;\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 start() {\n return this.emit(\"$onRequest\", this);\n }\n\n async finish() {\n await Promise.all([this.emit(\"$onResponse\", this), this.destroy()]);\n this.#isFinished = true;\n }\n\n isFinished() {\n return this.#isFinished;\n }\n\n isDone() {\n return this.request?.isAborted() || this.response?.isDone() || this.isFinished();\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"]}
|
|
@@ -1,24 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PlatformRouteDetails = void 0;
|
|
4
|
-
const platform_params_1 = require("@tsed/platform-params");
|
|
5
|
-
const schema_1 = require("@tsed/schema");
|
|
6
|
-
class PlatformRouteDetails extends schema_1.JsonOperationRoute {
|
|
7
|
-
constructor(options = {}) {
|
|
8
|
-
super(options);
|
|
9
|
-
this.rawBody = !!this.endpoint.parameters.find((param) => param.paramType === platform_params_1.ParamTypes.RAW_BODY);
|
|
10
|
-
}
|
|
11
|
-
toJSON() {
|
|
12
|
-
return {
|
|
13
|
-
method: this.method,
|
|
14
|
-
name: this.name,
|
|
15
|
-
url: this.url,
|
|
16
|
-
className: this.className,
|
|
17
|
-
methodClassName: this.methodClassName,
|
|
18
|
-
parameters: this.parameters,
|
|
19
|
-
rawBody: this.rawBody
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.PlatformRouteDetails = PlatformRouteDetails;
|
|
24
3
|
//# sourceMappingURL=PlatformRouteDetails.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformRouteDetails.js","sourceRoot":"","sources":["../../../src/domain/PlatformRouteDetails.ts"],"names":[],"mappings":"","sourcesContent":["export interface PlatformRouteDetails {\n method: string;\n name: string;\n url: string;\n className: string;\n methodClassName: string;\n}\n"]}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.All = exports.Options = exports.Head = exports.Delete = exports.Patch = exports.Put = exports.Post = exports.Get = exports.View = exports.Redirect = exports.Location = exports.AcceptMime = exports.Logger = exports.$log = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
require("@tsed/logger");
|
|
6
|
+
require("@tsed/logger-file");
|
|
7
|
+
tslib_1.__exportStar(require("@tsed/di"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("@tsed/platform-params"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("@tsed/platform-exceptions"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("@tsed/platform-response-filter"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("@tsed/platform-cache"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("@tsed/platform-middlewares"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("@tsed/components-scan"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("@tsed/platform-log-middleware"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("@tsed/platform-router"), exports);
|
|
16
|
+
var logger_1 = require("@tsed/logger");
|
|
17
|
+
Object.defineProperty(exports, "$log", { enumerable: true, get: function () { return logger_1.$log; } });
|
|
18
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
19
|
+
var schema_1 = require("@tsed/schema");
|
|
20
|
+
Object.defineProperty(exports, "AcceptMime", { enumerable: true, get: function () { return schema_1.AcceptMime; } });
|
|
21
|
+
Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return schema_1.Location; } });
|
|
22
|
+
Object.defineProperty(exports, "Redirect", { enumerable: true, get: function () { return schema_1.Redirect; } });
|
|
23
|
+
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return schema_1.View; } });
|
|
24
|
+
Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return schema_1.Get; } });
|
|
25
|
+
Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return schema_1.Post; } });
|
|
26
|
+
Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return schema_1.Put; } });
|
|
27
|
+
Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return schema_1.Patch; } });
|
|
28
|
+
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return schema_1.Delete; } });
|
|
29
|
+
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return schema_1.Head; } });
|
|
30
|
+
Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return schema_1.Options; } });
|
|
31
|
+
Object.defineProperty(exports, "All", { enumerable: true, get: function () { return schema_1.All; } });
|
|
32
|
+
//# sourceMappingURL=exports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports.js","sourceRoot":"","sources":["../../src/exports.ts"],"names":[],"mappings":";;;;AAAA,wBAAsB;AACtB,6BAA2B;AAE3B,mDAAyB;AACzB,gEAAsC;AACtC,oEAA0C;AAC1C,yEAA+C;AAC/C,+DAAqC;AACrC,qEAA2C;AAC3C,gEAAsC;AACtC,wEAA8C;AAC9C,gEAAsC;AAEtC,uCAA0C;AAAlC,8FAAA,IAAI,OAAA;AAAE,gGAAA,MAAM,OAAA;AAEpB,uCAAqH;AAA7G,oGAAA,UAAU,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,kGAAA,QAAQ,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,6FAAA,GAAG,OAAA;AAAE,+FAAA,KAAK,OAAA;AAAE,gGAAA,MAAM,OAAA;AAAE,8FAAA,IAAI,OAAA;AAAE,iGAAA,OAAO,OAAA;AAAE,6FAAA,GAAG,OAAA","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\";\nexport * from \"@tsed/platform-router\";\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/cjs/index.js
CHANGED
|
@@ -1,34 +1,62 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Automatically generated by barrelsby.
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Logger = exports.$log = void 0;
|
|
4
6
|
const tslib_1 = require("tslib");
|
|
5
|
-
require("
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
tslib_1.__exportStar(require("./exports"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./builder/PlatformBuilder"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./config/interfaces/ConverterSettings"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformLoggerSettings"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformMulterSettings"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformStaticsSettings"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./config/services/PlatformConfiguration"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./constants/routerOptions"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./decorators/multer/multerFileSize"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./decorators/multer/multerOptions"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./decorators/multer/multipartFile"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./decorators/params/error"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./decorators/params/next"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./decorators/params/request"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./decorators/params/response"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./domain/AnyToPromiseWithCtx"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./domain/EndpointMetadata"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./domain/PlatformContext"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./domain/PlatformRouteDetails"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./interfaces/AfterInit"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./interfaces/AfterListen"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./interfaces/AfterRoutesInit"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./interfaces/BeforeInit"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./interfaces/BeforeListen"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./interfaces/BeforeRoutesInit"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./interfaces/HandlerType"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./interfaces/IncomingEvent"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./interfaces/OnReady"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./interfaces/OnRequest"), exports);
|
|
36
|
+
tslib_1.__exportStar(require("./interfaces/OnResponse"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./interfaces/OnRoutesInit"), exports);
|
|
38
|
+
tslib_1.__exportStar(require("./interfaces/PlatformRouteOptions"), exports);
|
|
39
|
+
tslib_1.__exportStar(require("./interfaces/ResponseErrorObject"), exports);
|
|
40
|
+
tslib_1.__exportStar(require("./interfaces/Route"), exports);
|
|
41
|
+
tslib_1.__exportStar(require("./middlewares/PlatformAcceptMimesMiddleware"), exports);
|
|
42
|
+
tslib_1.__exportStar(require("./middlewares/PlatformMulterMiddleware"), exports);
|
|
43
|
+
tslib_1.__exportStar(require("./services/FakeAdapter"), exports);
|
|
44
|
+
tslib_1.__exportStar(require("./services/Platform"), exports);
|
|
45
|
+
tslib_1.__exportStar(require("./services/PlatformAdapter"), exports);
|
|
46
|
+
tslib_1.__exportStar(require("./services/PlatformApplication"), exports);
|
|
47
|
+
tslib_1.__exportStar(require("./services/PlatformHandler"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./services/PlatformMiddlewaresChain"), exports);
|
|
49
|
+
tslib_1.__exportStar(require("./services/PlatformRequest"), exports);
|
|
50
|
+
tslib_1.__exportStar(require("./services/PlatformResponse"), exports);
|
|
51
|
+
tslib_1.__exportStar(require("./services/PlatformTest"), exports);
|
|
52
|
+
tslib_1.__exportStar(require("./utils/createContext"), exports);
|
|
53
|
+
tslib_1.__exportStar(require("./utils/createHttpServer"), exports);
|
|
54
|
+
tslib_1.__exportStar(require("./utils/createHttpsServer"), exports);
|
|
55
|
+
tslib_1.__exportStar(require("./utils/createInjector"), exports);
|
|
56
|
+
tslib_1.__exportStar(require("./utils/ensureContext"), exports);
|
|
57
|
+
tslib_1.__exportStar(require("./utils/getStaticsOptions"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./utils/listenServer"), exports);
|
|
59
|
+
tslib_1.__exportStar(require("./utils/mapReturnedResponse"), exports);
|
|
60
|
+
tslib_1.__exportStar(require("./utils/printRoutes"), exports);
|
|
61
|
+
tslib_1.__exportStar(require("./utils/setResponseHeaders"), exports);
|
|
34
62
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,oDAA0B;AAC1B,oEAA0C;AAC1C,gFAAsD;AACtD,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,oEAA0C;AAC1C,mEAAyC;AACzC,wEAA8C;AAC9C,iEAAuC;AACvC,mEAAyC;AACzC,uEAA6C;AAC7C,kEAAwC;AACxC,oEAA0C;AAC1C,wEAA8C;AAC9C,mEAAyC;AACzC,qEAA2C;AAC3C,+DAAqC;AACrC,iEAAuC;AACvC,kEAAwC;AACxC,oEAA0C;AAC1C,4EAAkD;AAClD,2EAAiD;AACjD,6DAAmC;AACnC,sFAA4D;AAC5D,iFAAuD;AACvD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,kEAAwC;AACxC,gEAAsC;AACtC,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,gEAAsC;AACtC,oEAA0C;AAC1C,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,qEAA2C","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\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/EndpointMetadata\";\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 \"./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/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/ensureContext\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRouteOptions.js","sourceRoot":"","sources":["../../../src/interfaces/PlatformRouteOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {PathType} from \"
|
|
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 handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {TokenProvider} from \"@tsed/di\";\
|
|
1
|
+
{"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../src/interfaces/Route.ts"],"names":[],"mappings":"","sourcesContent":["import {Provider, TokenProvider} from \"@tsed/di\";\n\nexport interface Route extends Record<string, any> {\n route: string;\n token: TokenProvider;\n}\n\nexport interface RouteController {\n route: string;\n provider: Provider;\n}\n"]}
|
|
@@ -12,25 +12,26 @@ const platform_params_1 = require("@tsed/platform-params");
|
|
|
12
12
|
* @platform
|
|
13
13
|
*/
|
|
14
14
|
let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
|
|
15
|
+
acceptMimes;
|
|
15
16
|
use(ctx) {
|
|
16
17
|
const { endpoint, request } = ctx;
|
|
17
|
-
const mimes = (0, core_1.uniq)((
|
|
18
|
+
const mimes = (0, core_1.uniq)((endpoint?.get("acceptMimes") || []).concat(this.acceptMimes));
|
|
18
19
|
if (mimes.length && !request.accepts(mimes)) {
|
|
19
20
|
throw new exceptions_1.NotAcceptable(mimes.join(", "));
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
|
-
|
|
24
|
+
tslib_1.__decorate([
|
|
24
25
|
(0, di_1.Constant)("acceptMimes", []),
|
|
25
|
-
|
|
26
|
+
tslib_1.__metadata("design:type", Array)
|
|
26
27
|
], PlatformAcceptMimesMiddleware.prototype, "acceptMimes", void 0);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
tslib_1.__decorate([
|
|
29
|
+
tslib_1.__param(0, (0, platform_params_1.Context)()),
|
|
30
|
+
tslib_1.__metadata("design:type", Function),
|
|
31
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
32
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
32
33
|
], PlatformAcceptMimesMiddleware.prototype, "use", null);
|
|
33
|
-
PlatformAcceptMimesMiddleware =
|
|
34
|
+
PlatformAcceptMimesMiddleware = tslib_1.__decorate([
|
|
34
35
|
(0, platform_middlewares_1.Middleware)()
|
|
35
36
|
], PlatformAcceptMimesMiddleware);
|
|
36
37
|
exports.PlatformAcceptMimesMiddleware = PlatformAcceptMimesMiddleware;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";;;;AAAA,qCAAgC;AAChC,iCAAkC;AAClC,iDAA+C;AAC/C,qEAAyE;AACzE,2DAA8C;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;
|
|
1
|
+
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";;;;AAAA,qCAAgC;AAChC,iCAAkC;AAClC,iDAA+C;AAC/C,qEAAyE;AACzE,2DAA8C;AAE9C;;;GAGG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAExC,WAAW,CAAW;IAEf,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAA,WAAI,EAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,aAAa,CAAC,IAAI,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,0BAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3C;IACH,CAAC;CACF,CAAA;AAVC;IADC,IAAA,aAAQ,EAAC,aAAa,EAAE,EAAE,CAAC;;kEACN;AAEtB;IAAY,mBAAA,IAAA,yBAAO,GAAE,CAAA;;;;wDAOpB;AAXU,6BAA6B;IADzC,IAAA,iCAAU,GAAE;GACA,6BAA6B,CAYzC;AAZY,sEAA6B","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"]}
|
|
@@ -1,17 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var PlatformMulterMiddleware_1;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.PlatformMulterMiddleware = void 0;
|
|
4
|
+
exports.PlatformMulterMiddleware = exports.MulterException = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const di_1 = require("@tsed/di");
|
|
7
7
|
const exceptions_1 = require("@tsed/exceptions");
|
|
8
8
|
const platform_middlewares_1 = require("@tsed/platform-middlewares");
|
|
9
9
|
const platform_params_1 = require("@tsed/platform-params");
|
|
10
10
|
const PlatformApplication_1 = require("../services/PlatformApplication");
|
|
11
|
+
class MulterException extends exceptions_1.BadRequest {
|
|
12
|
+
constructor(er) {
|
|
13
|
+
super(er.message);
|
|
14
|
+
this.origin = er;
|
|
15
|
+
this.name = er.code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.MulterException = MulterException;
|
|
11
19
|
/**
|
|
12
20
|
* @middleware
|
|
13
21
|
*/
|
|
14
22
|
let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulterMiddleware {
|
|
23
|
+
settings;
|
|
24
|
+
app;
|
|
15
25
|
async use(ctx) {
|
|
16
26
|
try {
|
|
17
27
|
const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware_1);
|
|
@@ -27,28 +37,32 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
|
|
|
27
37
|
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
28
38
|
}
|
|
29
39
|
catch (er) {
|
|
30
|
-
|
|
40
|
+
if (er.code) {
|
|
41
|
+
throw new MulterException(er);
|
|
42
|
+
}
|
|
43
|
+
throw er;
|
|
31
44
|
}
|
|
32
45
|
}
|
|
33
46
|
getFields(conf) {
|
|
34
47
|
return conf.fields.map(({ name, maxCount }) => ({ name, maxCount }));
|
|
35
48
|
}
|
|
36
49
|
};
|
|
37
|
-
|
|
38
|
-
(0, di_1.
|
|
39
|
-
|
|
50
|
+
tslib_1.__decorate([
|
|
51
|
+
(0, di_1.Value)("multer", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840
|
|
52
|
+
,
|
|
53
|
+
tslib_1.__metadata("design:type", Object)
|
|
40
54
|
], PlatformMulterMiddleware.prototype, "settings", void 0);
|
|
41
|
-
|
|
55
|
+
tslib_1.__decorate([
|
|
42
56
|
(0, di_1.Inject)(),
|
|
43
|
-
|
|
57
|
+
tslib_1.__metadata("design:type", PlatformApplication_1.PlatformApplication)
|
|
44
58
|
], PlatformMulterMiddleware.prototype, "app", void 0);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
tslib_1.__decorate([
|
|
60
|
+
tslib_1.__param(0, (0, platform_params_1.Context)()),
|
|
61
|
+
tslib_1.__metadata("design:type", Function),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
63
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
50
64
|
], PlatformMulterMiddleware.prototype, "use", null);
|
|
51
|
-
PlatformMulterMiddleware = PlatformMulterMiddleware_1 =
|
|
65
|
+
PlatformMulterMiddleware = PlatformMulterMiddleware_1 = tslib_1.__decorate([
|
|
52
66
|
(0, platform_middlewares_1.Middleware)()
|
|
53
67
|
], PlatformMulterMiddleware);
|
|
54
68
|
exports.PlatformMulterMiddleware = PlatformMulterMiddleware;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;AAAA,iCAAuC;AACvC,iDAA4C;AAC5C,qEAAyE;AACzE,2DAA8C;AAG9C,yEAAoE;AAMpE,MAAa,eAAgB,SAAQ,uBAAU;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;AAND,0CAMC;AAED;;GAEG;AAEH,IAAa,wBAAwB,gCAArC,MAAa,wBAAwB;IAEzB,QAAQ,CAAyB;IAGjC,GAAG,CAAsB;IAEnC,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,IAAA,UAAK,EAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,4EAA4E;;;0DACtD;AAG3C;IADC,IAAA,WAAM,GAAE;sCACM,yCAAmB;qDAAC;AAEnC;IAAW,mBAAA,IAAA,yBAAO,GAAE,CAAA;;;;mDAuBnB;AA9BU,wBAAwB;IADpC,IAAA,iCAAU,GAAE;GACA,wBAAwB,CAmCpC;AAnCY,4DAAwB","sourcesContent":["import {Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport type {MulterError} from \"multer\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\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"]}
|