@tsed/common 7.0.0-beta.1 → 7.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/builder/PlatformBuilder.js +38 -27
- package/lib/cjs/builder/PlatformBuilder.js.map +1 -1
- package/lib/cjs/builder/PlatformControllerBuilder.js +5 -8
- package/lib/cjs/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/cjs/config/interfaces/PlatformMulterSettings.js.map +1 -1
- package/lib/cjs/config/services/PlatformConfiguration.js +2 -2
- package/lib/cjs/config/services/PlatformConfiguration.js.map +1 -1
- package/lib/cjs/decorators/multer/multipartFile.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.map +1 -1
- package/lib/cjs/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/cjs/exports.js +31 -0
- package/lib/cjs/exports.js.map +1 -0
- package/lib/cjs/index.js +68 -30
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js +8 -8
- package/lib/cjs/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js +25 -13
- package/lib/cjs/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/cjs/middlewares/__mock__/FakeCtrl.js +1 -1
- package/lib/cjs/middlewares/bindEndpointMiddleware.js.map +1 -1
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/services/FakeAdapter.js +55 -0
- package/lib/cjs/services/FakeAdapter.js.map +1 -0
- package/lib/cjs/services/Platform.js +30 -9
- package/lib/cjs/services/Platform.js.map +1 -1
- package/lib/cjs/services/PlatformAdapter.js +14 -0
- package/lib/cjs/services/PlatformAdapter.js.map +1 -0
- package/lib/cjs/services/PlatformApplication.js +9 -11
- package/lib/cjs/services/PlatformApplication.js.map +1 -1
- package/lib/cjs/services/PlatformHandler.js +10 -8
- package/lib/cjs/services/PlatformHandler.js.map +1 -1
- package/lib/cjs/services/PlatformMiddlewaresChain.js +56 -15
- package/lib/cjs/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/cjs/services/PlatformRequest.js +2 -2
- package/lib/cjs/services/PlatformResponse.js +5 -5
- package/lib/cjs/services/PlatformResponse.js.map +1 -1
- package/lib/cjs/services/PlatformRouter.js +14 -32
- package/lib/cjs/services/PlatformRouter.js.map +1 -1
- package/lib/cjs/services/PlatformTest.js +3 -2
- package/lib/cjs/services/PlatformTest.js.map +1 -1
- package/lib/cjs/utils/__mock__/Test1.js +8 -0
- package/lib/cjs/utils/__mock__/Test1.js.map +1 -0
- package/lib/cjs/utils/__mock__/Test2.js +8 -0
- package/lib/cjs/utils/__mock__/Test2.js.map +1 -0
- package/lib/cjs/utils/createContext.js +2 -2
- package/lib/cjs/utils/createContext.js.map +1 -1
- package/lib/cjs/utils/createHandlerMetadata.js +2 -2
- package/lib/cjs/utils/createHandlerMetadata.js.map +1 -1
- package/lib/cjs/utils/createHttpServer.js +3 -2
- package/lib/cjs/utils/createHttpServer.js.map +1 -1
- package/lib/cjs/utils/createHttpsServer.js +3 -2
- package/lib/cjs/utils/createHttpsServer.js.map +1 -1
- package/lib/cjs/utils/createInjector.js +11 -3
- package/lib/cjs/utils/createInjector.js.map +1 -1
- package/lib/cjs/utils/importProviders.js +29 -0
- package/lib/cjs/utils/importProviders.js.map +1 -0
- package/lib/cjs/utils/setResponseHeaders.js.map +1 -1
- package/lib/esm/builder/PlatformBuilder.js +25 -14
- package/lib/esm/builder/PlatformBuilder.js.map +1 -1
- package/lib/esm/builder/PlatformControllerBuilder.js +8 -11
- package/lib/esm/builder/PlatformControllerBuilder.js.map +1 -1
- package/lib/esm/config/interfaces/PlatformMulterSettings.js.map +1 -1
- 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/domain/ControllerProvider.js +1 -1
- package/lib/esm/domain/EndpointMetadata.js +1 -66
- package/lib/esm/domain/EndpointMetadata.js.map +1 -1
- package/lib/esm/domain/HandlerMetadata.js +1 -1
- package/lib/esm/domain/PlatformContext.js +3 -3
- package/lib/esm/domain/PlatformContext.js.map +1 -1
- package/lib/esm/domain/PlatformRouteDetails.js.map +1 -1
- package/lib/esm/exports.js +13 -0
- package/lib/esm/exports.js.map +1 -0
- package/lib/esm/index.js +68 -27
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/PlatformRouteOptions.js.map +1 -1
- package/lib/esm/middlewares/PlatformMulterMiddleware.js +16 -5
- package/lib/esm/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/middlewares/bindEndpointMiddleware.js.map +1 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/services/FakeAdapter.js +51 -0
- package/lib/esm/services/FakeAdapter.js.map +1 -0
- package/lib/esm/services/Platform.js +31 -10
- package/lib/esm/services/Platform.js.map +1 -1
- package/lib/esm/services/PlatformAdapter.js +10 -0
- package/lib/esm/services/PlatformAdapter.js.map +1 -0
- package/lib/esm/services/PlatformApplication.js +11 -13
- package/lib/esm/services/PlatformApplication.js.map +1 -1
- package/lib/esm/services/PlatformHandler.js +11 -9
- package/lib/esm/services/PlatformHandler.js.map +1 -1
- package/lib/esm/services/PlatformMiddlewaresChain.js +61 -20
- package/lib/esm/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/services/PlatformResponse.js +1 -1
- package/lib/esm/services/PlatformResponse.js.map +1 -1
- package/lib/esm/services/PlatformRouter.js +13 -31
- package/lib/esm/services/PlatformRouter.js.map +1 -1
- package/lib/esm/services/PlatformTest.js +7 -7
- package/lib/esm/services/PlatformTest.js.map +1 -1
- package/lib/esm/utils/__mock__/Test1.js +4 -0
- package/lib/esm/utils/__mock__/Test1.js.map +1 -0
- package/lib/esm/utils/__mock__/Test2.js +4 -0
- package/lib/esm/utils/__mock__/Test2.js.map +1 -0
- package/lib/esm/utils/createContext.js +5 -5
- package/lib/esm/utils/createContext.js.map +1 -1
- package/lib/esm/utils/createHandlerMetadata.js +3 -3
- package/lib/esm/utils/createHandlerMetadata.js.map +1 -1
- package/lib/esm/utils/createHttpServer.js +4 -3
- package/lib/esm/utils/createHttpServer.js.map +1 -1
- package/lib/esm/utils/createHttpsServer.js +4 -3
- package/lib/esm/utils/createHttpsServer.js.map +1 -1
- package/lib/esm/utils/createInjector.js +18 -10
- package/lib/esm/utils/createInjector.js.map +1 -1
- package/lib/esm/utils/importProviders.js +25 -0
- package/lib/esm/utils/importProviders.js.map +1 -0
- package/lib/esm/utils/setResponseHeaders.js.map +1 -1
- package/lib/esm/utils/useCtxHandler.js +1 -1
- package/lib/types/builder/PlatformBuilder.d.ts +7 -6
- package/lib/types/builder/PlatformControllerBuilder.d.ts +2 -1
- package/lib/types/config/interfaces/PlatformMulterSettings.d.ts +6 -130
- package/lib/types/config/services/PlatformConfiguration.d.ts +2 -1
- package/lib/types/domain/EndpointMetadata.d.ts +1 -50
- package/lib/types/domain/PlatformContext.d.ts +1 -1
- package/lib/types/domain/PlatformRouteDetails.d.ts +2 -3
- package/lib/types/exports.d.ts +12 -0
- package/lib/types/index.d.ts +65 -17
- package/lib/types/interfaces/PlatformRouteOptions.d.ts +1 -1
- package/lib/types/middlewares/PlatformMulterMiddleware.d.ts +8 -3
- package/lib/types/middlewares/bindEndpointMiddleware.d.ts +2 -1
- package/lib/types/services/FakeAdapter.d.ts +30 -0
- package/lib/types/services/Platform.d.ts +10 -1
- package/lib/types/services/PlatformAdapter.d.ts +47 -0
- package/lib/types/services/PlatformApplication.d.ts +3 -3
- package/lib/types/services/PlatformHandler.d.ts +1 -1
- package/lib/types/services/PlatformMiddlewaresChain.d.ts +6 -2
- package/lib/types/services/PlatformResponse.d.ts +6 -6
- package/lib/types/services/PlatformRouter.d.ts +10 -7
- package/lib/types/services/PlatformTest.d.ts +2 -2
- package/lib/types/utils/__mock__/Test1.d.ts +3 -0
- package/lib/types/utils/__mock__/Test2.d.ts +3 -0
- package/lib/types/utils/createHandlerMetadata.d.ts +1 -1
- package/lib/types/utils/createHttpServer.d.ts +1 -1
- package/lib/types/utils/createHttpsServer.d.ts +2 -1
- package/lib/types/utils/createInjector.d.ts +5 -3
- package/lib/types/utils/importProviders.d.ts +10 -0
- package/package.json +38 -26
- package/readme.md +50 -57
- package/tsconfig.compile.esm.json +2 -12
- package/lib/cjs/config/index.js +0 -7
- package/lib/cjs/config/index.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/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/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/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/index.js +0 -12
- package/lib/cjs/services/index.js.map +0 -1
- package/lib/cjs/utils/index.js +0 -11
- package/lib/cjs/utils/index.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/index.js +0 -5
- package/lib/esm/config/interfaces/index.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/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/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/index.js +0 -9
- package/lib/esm/services/index.js.map +0 -1
- package/lib/esm/utils/index.js +0 -8
- package/lib/esm/utils/index.js.map +0 -1
- package/lib/types/config/index.d.ts +0 -3
- package/lib/types/config/interfaces/index.d.ts +0 -97
- 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/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/index.d.ts +0 -3
- package/lib/types/services/FakeRawDriver.d.ts +0 -15
- package/lib/types/services/index.d.ts +0 -8
- package/lib/types/utils/index.d.ts +0 -7
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
var logger_1 = require("@tsed/logger");
|
|
16
|
+
Object.defineProperty(exports, "$log", { enumerable: true, get: function () { return logger_1.$log; } });
|
|
17
|
+
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return logger_1.Logger; } });
|
|
18
|
+
var schema_1 = require("@tsed/schema");
|
|
19
|
+
Object.defineProperty(exports, "AcceptMime", { enumerable: true, get: function () { return schema_1.AcceptMime; } });
|
|
20
|
+
Object.defineProperty(exports, "Location", { enumerable: true, get: function () { return schema_1.Location; } });
|
|
21
|
+
Object.defineProperty(exports, "Redirect", { enumerable: true, get: function () { return schema_1.Redirect; } });
|
|
22
|
+
Object.defineProperty(exports, "View", { enumerable: true, get: function () { return schema_1.View; } });
|
|
23
|
+
Object.defineProperty(exports, "Get", { enumerable: true, get: function () { return schema_1.Get; } });
|
|
24
|
+
Object.defineProperty(exports, "Post", { enumerable: true, get: function () { return schema_1.Post; } });
|
|
25
|
+
Object.defineProperty(exports, "Put", { enumerable: true, get: function () { return schema_1.Put; } });
|
|
26
|
+
Object.defineProperty(exports, "Patch", { enumerable: true, get: function () { return schema_1.Patch; } });
|
|
27
|
+
Object.defineProperty(exports, "Delete", { enumerable: true, get: function () { return schema_1.Delete; } });
|
|
28
|
+
Object.defineProperty(exports, "Head", { enumerable: true, get: function () { return schema_1.Head; } });
|
|
29
|
+
Object.defineProperty(exports, "Options", { enumerable: true, get: function () { return schema_1.Options; } });
|
|
30
|
+
Object.defineProperty(exports, "All", { enumerable: true, get: function () { return schema_1.All; } });
|
|
31
|
+
//# 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;AAE9C,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\";\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,72 @@
|
|
|
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("./builder/PlatformControllerBuilder"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./config/interfaces/ConverterSettings"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./config/interfaces/EndpointDirectoriesSettings"), exports);
|
|
12
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformLoggerSettings"), exports);
|
|
13
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformMulterSettings"), exports);
|
|
14
|
+
tslib_1.__exportStar(require("./config/interfaces/PlatformStaticsSettings"), exports);
|
|
15
|
+
tslib_1.__exportStar(require("./config/services/PlatformConfiguration"), exports);
|
|
16
|
+
tslib_1.__exportStar(require("./constants/routerOptions"), exports);
|
|
17
|
+
tslib_1.__exportStar(require("./decorators/httpServer"), exports);
|
|
18
|
+
tslib_1.__exportStar(require("./decorators/httpsServer"), exports);
|
|
19
|
+
tslib_1.__exportStar(require("./decorators/multer/multerFileSize"), exports);
|
|
20
|
+
tslib_1.__exportStar(require("./decorators/multer/multerOptions"), exports);
|
|
21
|
+
tslib_1.__exportStar(require("./decorators/multer/multipartFile"), exports);
|
|
22
|
+
tslib_1.__exportStar(require("./decorators/params/error"), exports);
|
|
23
|
+
tslib_1.__exportStar(require("./decorators/params/next"), exports);
|
|
24
|
+
tslib_1.__exportStar(require("./decorators/params/request"), exports);
|
|
25
|
+
tslib_1.__exportStar(require("./decorators/params/response"), exports);
|
|
26
|
+
tslib_1.__exportStar(require("./domain/AnyToPromiseWithCtx"), exports);
|
|
27
|
+
tslib_1.__exportStar(require("./domain/ControllerProvider"), exports);
|
|
28
|
+
tslib_1.__exportStar(require("./domain/EndpointMetadata"), exports);
|
|
29
|
+
tslib_1.__exportStar(require("./domain/HandlerMetadata"), exports);
|
|
30
|
+
tslib_1.__exportStar(require("./domain/PlatformContext"), exports);
|
|
31
|
+
tslib_1.__exportStar(require("./domain/PlatformRouteDetails"), exports);
|
|
32
|
+
tslib_1.__exportStar(require("./interfaces/AfterInit"), exports);
|
|
33
|
+
tslib_1.__exportStar(require("./interfaces/AfterListen"), exports);
|
|
34
|
+
tslib_1.__exportStar(require("./interfaces/AfterRoutesInit"), exports);
|
|
35
|
+
tslib_1.__exportStar(require("./interfaces/BeforeInit"), exports);
|
|
36
|
+
tslib_1.__exportStar(require("./interfaces/BeforeListen"), exports);
|
|
37
|
+
tslib_1.__exportStar(require("./interfaces/BeforeRoutesInit"), exports);
|
|
38
|
+
tslib_1.__exportStar(require("./interfaces/HandlerType"), exports);
|
|
39
|
+
tslib_1.__exportStar(require("./interfaces/IncomingEvent"), exports);
|
|
40
|
+
tslib_1.__exportStar(require("./interfaces/OnReady"), exports);
|
|
41
|
+
tslib_1.__exportStar(require("./interfaces/OnRequest"), exports);
|
|
42
|
+
tslib_1.__exportStar(require("./interfaces/OnResponse"), exports);
|
|
43
|
+
tslib_1.__exportStar(require("./interfaces/OnRoutesInit"), exports);
|
|
44
|
+
tslib_1.__exportStar(require("./interfaces/PlatformRouteOptions"), exports);
|
|
45
|
+
tslib_1.__exportStar(require("./interfaces/ResponseErrorObject"), exports);
|
|
46
|
+
tslib_1.__exportStar(require("./interfaces/Route"), exports);
|
|
47
|
+
tslib_1.__exportStar(require("./middlewares/PlatformAcceptMimesMiddleware"), exports);
|
|
48
|
+
tslib_1.__exportStar(require("./middlewares/PlatformMulterMiddleware"), exports);
|
|
49
|
+
tslib_1.__exportStar(require("./middlewares/bindEndpointMiddleware"), exports);
|
|
50
|
+
tslib_1.__exportStar(require("./services/FakeAdapter"), exports);
|
|
51
|
+
tslib_1.__exportStar(require("./services/Platform"), exports);
|
|
52
|
+
tslib_1.__exportStar(require("./services/PlatformAdapter"), exports);
|
|
53
|
+
tslib_1.__exportStar(require("./services/PlatformApplication"), exports);
|
|
54
|
+
tslib_1.__exportStar(require("./services/PlatformHandler"), exports);
|
|
55
|
+
tslib_1.__exportStar(require("./services/PlatformMiddlewaresChain"), exports);
|
|
56
|
+
tslib_1.__exportStar(require("./services/PlatformRequest"), exports);
|
|
57
|
+
tslib_1.__exportStar(require("./services/PlatformResponse"), exports);
|
|
58
|
+
tslib_1.__exportStar(require("./services/PlatformRouter"), exports);
|
|
59
|
+
tslib_1.__exportStar(require("./services/PlatformTest"), exports);
|
|
60
|
+
tslib_1.__exportStar(require("./utils/createContext"), exports);
|
|
61
|
+
tslib_1.__exportStar(require("./utils/createHandlerMetadata"), exports);
|
|
62
|
+
tslib_1.__exportStar(require("./utils/createHttpServer"), exports);
|
|
63
|
+
tslib_1.__exportStar(require("./utils/createHttpsServer"), exports);
|
|
64
|
+
tslib_1.__exportStar(require("./utils/createInjector"), exports);
|
|
65
|
+
tslib_1.__exportStar(require("./utils/getStaticsOptions"), exports);
|
|
66
|
+
tslib_1.__exportStar(require("./utils/importProviders"), exports);
|
|
67
|
+
tslib_1.__exportStar(require("./utils/listenServer"), exports);
|
|
68
|
+
tslib_1.__exportStar(require("./utils/mapReturnedResponse"), exports);
|
|
69
|
+
tslib_1.__exportStar(require("./utils/printRoutes"), exports);
|
|
70
|
+
tslib_1.__exportStar(require("./utils/setResponseHeaders"), exports);
|
|
71
|
+
tslib_1.__exportStar(require("./utils/useCtxHandler"), exports);
|
|
34
72
|
//# 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,8EAAoD;AACpD,gFAAsD;AACtD,0FAAgE;AAChE,qFAA2D;AAC3D,qFAA2D;AAC3D,sFAA4D;AAC5D,kFAAwD;AACxD,oEAA0C;AAC1C,kEAAwC;AACxC,mEAAyC;AACzC,6EAAmD;AACnD,4EAAkD;AAClD,4EAAkD;AAClD,oEAA0C;AAC1C,mEAAyC;AACzC,sEAA4C;AAC5C,uEAA6C;AAC7C,uEAA6C;AAC7C,sEAA4C;AAC5C,oEAA0C;AAC1C,mEAAyC;AACzC,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,+EAAqD;AACrD,iEAAuC;AACvC,8DAAoC;AACpC,qEAA2C;AAC3C,yEAA+C;AAC/C,qEAA2C;AAC3C,8EAAoD;AACpD,qEAA2C;AAC3C,sEAA4C;AAC5C,oEAA0C;AAC1C,kEAAwC;AACxC,gEAAsC;AACtC,wEAA8C;AAC9C,mEAAyC;AACzC,oEAA0C;AAC1C,iEAAuC;AACvC,oEAA0C;AAC1C,kEAAwC;AACxC,+DAAqC;AACrC,sEAA4C;AAC5C,8DAAoC;AACpC,qEAA2C;AAC3C,gEAAsC","sourcesContent":["/**\n * @file Automatically generated by barrelsby.\n */\n\nexport * from \"./exports\";\nexport * from \"./builder/PlatformBuilder\";\nexport * from \"./builder/PlatformControllerBuilder\";\nexport * from \"./config/interfaces/ConverterSettings\";\nexport * from \"./config/interfaces/EndpointDirectoriesSettings\";\nexport * from \"./config/interfaces/PlatformLoggerSettings\";\nexport * from \"./config/interfaces/PlatformMulterSettings\";\nexport * from \"./config/interfaces/PlatformStaticsSettings\";\nexport * from \"./config/services/PlatformConfiguration\";\nexport * from \"./constants/routerOptions\";\nexport * from \"./decorators/httpServer\";\nexport * from \"./decorators/httpsServer\";\nexport * from \"./decorators/multer/multerFileSize\";\nexport * from \"./decorators/multer/multerOptions\";\nexport * from \"./decorators/multer/multipartFile\";\nexport * from \"./decorators/params/error\";\nexport * from \"./decorators/params/next\";\nexport * from \"./decorators/params/request\";\nexport * from \"./decorators/params/response\";\nexport * from \"./domain/AnyToPromiseWithCtx\";\nexport * from \"./domain/ControllerProvider\";\nexport * from \"./domain/EndpointMetadata\";\nexport * from \"./domain/HandlerMetadata\";\nexport * from \"./domain/PlatformContext\";\nexport * from \"./domain/PlatformRouteDetails\";\nexport * from \"./interfaces/AfterInit\";\nexport * from \"./interfaces/AfterListen\";\nexport * from \"./interfaces/AfterRoutesInit\";\nexport * from \"./interfaces/BeforeInit\";\nexport * from \"./interfaces/BeforeListen\";\nexport * from \"./interfaces/BeforeRoutesInit\";\nexport * from \"./interfaces/HandlerType\";\nexport * from \"./interfaces/IncomingEvent\";\nexport * from \"./interfaces/OnReady\";\nexport * from \"./interfaces/OnRequest\";\nexport * from \"./interfaces/OnResponse\";\nexport * from \"./interfaces/OnRoutesInit\";\nexport * from \"./interfaces/PlatformRouteOptions\";\nexport * from \"./interfaces/ResponseErrorObject\";\nexport * from \"./interfaces/Route\";\nexport * from \"./middlewares/PlatformAcceptMimesMiddleware\";\nexport * from \"./middlewares/PlatformMulterMiddleware\";\nexport * from \"./middlewares/bindEndpointMiddleware\";\nexport * from \"./services/FakeAdapter\";\nexport * from \"./services/Platform\";\nexport * from \"./services/PlatformAdapter\";\nexport * from \"./services/PlatformApplication\";\nexport * from \"./services/PlatformHandler\";\nexport * from \"./services/PlatformMiddlewaresChain\";\nexport * from \"./services/PlatformRequest\";\nexport * from \"./services/PlatformResponse\";\nexport * from \"./services/PlatformRouter\";\nexport * from \"./services/PlatformTest\";\nexport * from \"./utils/createContext\";\nexport * from \"./utils/createHandlerMetadata\";\nexport * from \"./utils/createHttpServer\";\nexport * from \"./utils/createHttpsServer\";\nexport * from \"./utils/createInjector\";\nexport * from \"./utils/getStaticsOptions\";\nexport * from \"./utils/importProviders\";\nexport * from \"./utils/listenServer\";\nexport * from \"./utils/mapReturnedResponse\";\nexport * from \"./utils/printRoutes\";\nexport * from \"./utils/setResponseHeaders\";\nexport * from \"./utils/useCtxHandler\";\n"]}
|
|
@@ -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 isFinal?: boolean;\n handlers: any[];\n}\n\n/**\n * @ignore\n */\nexport type PlatformRouteWithoutHandlers = Partial<Omit<PlatformRouteOptions, \"handlers\">>;\n"]}
|
|
@@ -20,17 +20,17 @@ let PlatformAcceptMimesMiddleware = class PlatformAcceptMimesMiddleware {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
tslib_1.__decorate([
|
|
24
24
|
(0, di_1.Constant)("acceptMimes", []),
|
|
25
|
-
|
|
25
|
+
tslib_1.__metadata("design:type", Array)
|
|
26
26
|
], PlatformAcceptMimesMiddleware.prototype, "acceptMimes", void 0);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
tslib_1.__decorate([
|
|
28
|
+
tslib_1.__param(0, (0, platform_params_1.Context)()),
|
|
29
|
+
tslib_1.__metadata("design:type", Function),
|
|
30
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
31
|
+
tslib_1.__metadata("design:returntype", void 0)
|
|
32
32
|
], PlatformAcceptMimesMiddleware.prototype, "use", null);
|
|
33
|
-
PlatformAcceptMimesMiddleware =
|
|
33
|
+
PlatformAcceptMimesMiddleware = tslib_1.__decorate([
|
|
34
34
|
(0, platform_middlewares_1.Middleware)()
|
|
35
35
|
], PlatformAcceptMimesMiddleware);
|
|
36
36
|
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;IAIjC,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAA,WAAI,EAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,aAAa,CAAC,KAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,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,
|
|
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;IAIjC,GAAG,CAAY,GAAY;QAChC,MAAM,EAAC,QAAQ,EAAE,OAAO,EAAC,GAAG,GAAG,CAAC;QAChC,MAAM,KAAK,GAAG,IAAA,WAAI,EAAC,CAAC,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,aAAa,CAAC,KAAI,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAElF,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;YAC3C,MAAM,IAAI,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,13 +1,21 @@
|
|
|
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
|
*/
|
|
@@ -27,28 +35,32 @@ let PlatformMulterMiddleware = PlatformMulterMiddleware_1 = class PlatformMulter
|
|
|
27
35
|
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
28
36
|
}
|
|
29
37
|
catch (er) {
|
|
30
|
-
|
|
38
|
+
if (er.code) {
|
|
39
|
+
throw new MulterException(er);
|
|
40
|
+
}
|
|
41
|
+
throw er;
|
|
31
42
|
}
|
|
32
43
|
}
|
|
33
44
|
getFields(conf) {
|
|
34
45
|
return conf.fields.map(({ name, maxCount }) => ({ name, maxCount }));
|
|
35
46
|
}
|
|
36
47
|
};
|
|
37
|
-
|
|
38
|
-
(0, di_1.
|
|
39
|
-
|
|
48
|
+
tslib_1.__decorate([
|
|
49
|
+
(0, di_1.Value)("multer", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840
|
|
50
|
+
,
|
|
51
|
+
tslib_1.__metadata("design:type", Object)
|
|
40
52
|
], PlatformMulterMiddleware.prototype, "settings", void 0);
|
|
41
|
-
|
|
53
|
+
tslib_1.__decorate([
|
|
42
54
|
(0, di_1.Inject)(),
|
|
43
|
-
|
|
55
|
+
tslib_1.__metadata("design:type", PlatformApplication_1.PlatformApplication)
|
|
44
56
|
], PlatformMulterMiddleware.prototype, "app", void 0);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
tslib_1.__param(0, (0, platform_params_1.Context)()),
|
|
59
|
+
tslib_1.__metadata("design:type", Function),
|
|
60
|
+
tslib_1.__metadata("design:paramtypes", [Object]),
|
|
61
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
50
62
|
], PlatformMulterMiddleware.prototype, "use", null);
|
|
51
|
-
PlatformMulterMiddleware = PlatformMulterMiddleware_1 =
|
|
63
|
+
PlatformMulterMiddleware = PlatformMulterMiddleware_1 = tslib_1.__decorate([
|
|
52
64
|
(0, platform_middlewares_1.Middleware)()
|
|
53
65
|
], PlatformMulterMiddleware);
|
|
54
66
|
exports.PlatformMulterMiddleware = PlatformMulterMiddleware;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";;;;;AACA,iCAAiD;AACjD,iDAA4C;AAC5C,qEAAyE;AACzE,2DAA8C;AAE9C,yEAAoE;AAOpE,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;IAOnC,KAAK,CAAC,GAAG,CAAY,GAAY;QAC/B,IAAI;YACF,MAAM,EAAC,MAAM,EAAE,OAAO,GAAG,EAAE,EAAC,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,0BAAwB,CAAC,CAAC;YAC1E,MAAM,QAAQ,GAA2B;gBACvC,GAAG,IAAI,CAAC,QAAQ;gBAChB,GAAG,OAAO;aACX,CAAC;YAEF,0BAA0B;YAC1B,IAAI,QAAQ,CAAC,OAAO,EAAE;gBACpB,OAAO,QAAQ,CAAC,IAAI,CAAC;aACtB;YAED,MAAM,UAAU,GAAQ,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC,CAAC,CAAC,CAAC;YAEnF,OAAO,MAAM,UAAU,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;SAC9D;QAAC,OAAO,EAAE,EAAE;YACX,IAAI,EAAE,CAAC,IAAI,EAAE;gBACX,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,CAAC;aAC/B;YAED,MAAM,EAAE,CAAC;SACV;IACH,CAAC;IAES,SAAS,CAAC,IAAwB;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,EAAE,EAAE,CAAC,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC,CAAC;IACnE,CAAC;CACF,CAAA;AAjCC;IADC,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 type {MulterError} from \"multer\";\nimport {Constant, Inject, Value} from \"@tsed/di\";\nimport {BadRequest} from \"@tsed/exceptions\";\nimport {Middleware, MiddlewareMethods} from \"@tsed/platform-middlewares\";\nimport {Context} from \"@tsed/platform-params\";\nimport {PlatformMulterField, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformApplication} from \"../services/PlatformApplication\";\nimport {PlatformConfiguration} from \"../config/services/PlatformConfiguration\";\n\nexport interface MulterInputOptions {\n fields: PlatformMulterField[];\n}\n\nexport class MulterException extends BadRequest {\n constructor(er: MulterError) {\n super(er.message);\n this.origin = er;\n this.name = er.code;\n }\n}\n\n/**\n * @middleware\n */\n@Middleware()\nexport class PlatformMulterMiddleware implements MiddlewareMethods {\n @Value(\"multer\", {}) // NOTE: don't use constant to getting multer configuration. See issue #1840\n protected settings: PlatformMulterSettings;\n\n @Inject()\n protected app: PlatformApplication;\n\n async use(@Context() ctx: Context) {\n try {\n const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);\n const settings: PlatformMulterSettings = {\n ...this.settings,\n ...options\n };\n\n /* istanbul ignore next */\n if (settings.storage) {\n delete settings.dest;\n }\n\n const middleware: any = this.app.multer(settings).fields(this.getFields({fields}));\n\n return await middleware(ctx.getRequest(), ctx.getResponse());\n } catch (er) {\n if (er.code) {\n throw new MulterException(er);\n }\n\n throw er;\n }\n }\n\n protected getFields(conf: MulterInputOptions) {\n return conf.fields.map(({name, maxCount}) => ({name, maxCount}));\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"bindEndpointMiddleware.js","sourceRoot":"","sources":["../../../src/middlewares/bindEndpointMiddleware.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH,SAAgB,sBAAsB,CAAC,QAA0B;IAC/D,OAAO,CAAC,GAAoB,EAAE,EAAE;QAC9B,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC,CAAC;AACJ,CAAC;AAJD,wDAIC","sourcesContent":["import type {EndpointMetadata} from \"../domain/EndpointMetadata\";\nimport type {PlatformContext} from \"../domain/PlatformContext\";\n\n/**\n * @ignore\n */\nexport function bindEndpointMiddleware(endpoint: EndpointMetadata) {\n return (ctx: PlatformContext) => {\n ctx.endpoint = endpoint;\n };\n}\n"]}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FakeAdapter = void 0;
|
|
4
|
+
class FakeAdapter {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.providers = [];
|
|
7
|
+
}
|
|
8
|
+
static createFakeRawDriver() {
|
|
9
|
+
// istanbul ignore next
|
|
10
|
+
function FakeRawDriver() { }
|
|
11
|
+
// istanbul ignore next
|
|
12
|
+
function use() {
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
FakeRawDriver.use = use;
|
|
16
|
+
FakeRawDriver.all = use;
|
|
17
|
+
FakeRawDriver.get = use;
|
|
18
|
+
FakeRawDriver.patch = use;
|
|
19
|
+
FakeRawDriver.post = use;
|
|
20
|
+
FakeRawDriver.put = use;
|
|
21
|
+
FakeRawDriver.head = use;
|
|
22
|
+
FakeRawDriver.delete = use;
|
|
23
|
+
FakeRawDriver.options = use;
|
|
24
|
+
return FakeRawDriver;
|
|
25
|
+
}
|
|
26
|
+
app() {
|
|
27
|
+
const app = FakeAdapter.createFakeRawDriver();
|
|
28
|
+
return {
|
|
29
|
+
app,
|
|
30
|
+
callback() {
|
|
31
|
+
return app;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
multipart(options) {
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
router(routerOptions) {
|
|
39
|
+
const router = FakeAdapter.createFakeRawDriver();
|
|
40
|
+
return {
|
|
41
|
+
router,
|
|
42
|
+
callback() {
|
|
43
|
+
return router;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
statics(endpoint, options) {
|
|
48
|
+
return {};
|
|
49
|
+
}
|
|
50
|
+
bodyParser(type) {
|
|
51
|
+
return () => { };
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.FakeAdapter = FakeAdapter;
|
|
55
|
+
//# sourceMappingURL=FakeAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FakeAdapter.js","sourceRoot":"","sources":["../../../src/services/FakeAdapter.ts"],"names":[],"mappings":";;;AAKA,MAAa,WAAW;IAAxB;QACE,cAAS,GAAmB,EAAE,CAAC;IAuDjC,CAAC;IArDC,MAAM,CAAC,mBAAmB;QACxB,uBAAuB;QACvB,SAAS,aAAa,KAAI,CAAC;QAE3B,uBAAuB;QACvB,SAAS,GAAG;YACV,OAAO,IAAI,CAAC;QACd,CAAC;QAED,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,KAAK,GAAG,GAAG,CAAC;QAC1B,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;QACxB,aAAa,CAAC,IAAI,GAAG,GAAG,CAAC;QACzB,aAAa,CAAC,MAAM,GAAG,GAAG,CAAC;QAC3B,aAAa,CAAC,OAAO,GAAG,GAAG,CAAC;QAE5B,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,GAAG;QACD,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QAC9C,OAAO;YACL,GAAG;YACH,QAAQ;gBACN,OAAO,GAAG,CAAC;YACb,CAAC;SACF,CAAC;IACJ,CAAC;IAED,SAAS,CAAC,OAA+B;QACvC,OAAO,EAAS,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,aAAkB;QACvB,MAAM,MAAM,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACjD,OAAO;YACL,MAAM;YACN,QAAQ;gBACN,OAAO,MAAM,CAAC;YAChB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,CAAC,QAAgB,EAAE,OAA+B;QACvD,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,IAAY;QACrB,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAClB,CAAC;CACF;AAxDD,kCAwDC","sourcesContent":["import {ProviderOpts} from \"@tsed/di\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\n\nexport class FakeAdapter implements PlatformAdapter<any, any> {\n providers: ProviderOpts[] = [];\n\n static createFakeRawDriver() {\n // istanbul ignore next\n function FakeRawDriver() {}\n\n // istanbul ignore next\n function use() {\n return this;\n }\n\n FakeRawDriver.use = use;\n FakeRawDriver.all = use;\n FakeRawDriver.get = use;\n FakeRawDriver.patch = use;\n FakeRawDriver.post = use;\n FakeRawDriver.put = use;\n FakeRawDriver.head = use;\n FakeRawDriver.delete = use;\n FakeRawDriver.options = use;\n\n return FakeRawDriver;\n }\n\n app(): {app: any; callback(): any} {\n const app = FakeAdapter.createFakeRawDriver();\n return {\n app,\n callback() {\n return app;\n }\n };\n }\n\n multipart(options: PlatformMulterSettings): PlatformMulter {\n return {} as any;\n }\n\n router(routerOptions: any): {router: any; callback(): any} {\n const router = FakeAdapter.createFakeRawDriver();\n return {\n router,\n callback() {\n return router;\n }\n };\n }\n\n statics(endpoint: string, options: PlatformStaticsOptions): any {\n return {};\n }\n\n bodyParser(type: string): any {\n return () => {};\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const di_1 = require("@tsed/di");
|
|
6
6
|
const schema_1 = require("@tsed/schema");
|
|
7
7
|
const PlatformControllerBuilder_1 = require("../builder/PlatformControllerBuilder");
|
|
8
|
-
const
|
|
8
|
+
const PlatformRouteDetails_1 = require("../domain/PlatformRouteDetails");
|
|
9
9
|
const PlatformApplication_1 = require("./PlatformApplication");
|
|
10
10
|
const PlatformMiddlewaresChain_1 = require("./PlatformMiddlewaresChain");
|
|
11
11
|
/**
|
|
@@ -38,11 +38,8 @@ let Platform = class Platform {
|
|
|
38
38
|
if (!provider || provider.hasParent()) {
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
|
+
this._controllers.push(...this.getAllControllers(basePath, token));
|
|
41
42
|
const ctrlPath = (0, schema_1.concatPath)(basePath, schema_1.JsonEntityStore.from(provider.token).path);
|
|
42
|
-
this._controllers.push({
|
|
43
|
-
route: ctrlPath,
|
|
44
|
-
provider
|
|
45
|
-
});
|
|
46
43
|
this.app.use(ctrlPath, ...[].concat((0, PlatformControllerBuilder_1.getRouter)(injector, provider).callback()));
|
|
47
44
|
this._routes = (0, schema_1.getOperationsRoutes)(provider.token, {
|
|
48
45
|
withChildren: true,
|
|
@@ -50,11 +47,11 @@ let Platform = class Platform {
|
|
|
50
47
|
}).reduce((routes, operationRoute) => {
|
|
51
48
|
if (injector.hasProvider(token)) {
|
|
52
49
|
const provider = injector.getProvider(operationRoute.token);
|
|
53
|
-
const route = new
|
|
50
|
+
const route = new PlatformRouteDetails_1.PlatformRouteDetails({
|
|
54
51
|
...operationRoute,
|
|
55
52
|
provider
|
|
56
53
|
});
|
|
57
|
-
|
|
54
|
+
routes = routes.concat(route);
|
|
58
55
|
}
|
|
59
56
|
return routes;
|
|
60
57
|
}, this._routes);
|
|
@@ -67,6 +64,10 @@ let Platform = class Platform {
|
|
|
67
64
|
getRoutes() {
|
|
68
65
|
return this._routes;
|
|
69
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* Get all controllers mounted on the application.
|
|
69
|
+
* @returns {RouteController[]}
|
|
70
|
+
*/
|
|
70
71
|
getMountedControllers() {
|
|
71
72
|
return this._controllers;
|
|
72
73
|
}
|
|
@@ -83,6 +84,26 @@ let Platform = class Platform {
|
|
|
83
84
|
(0, PlatformControllerBuilder_1.createRouter)(injector, provider);
|
|
84
85
|
});
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Get all router controllers from the controller token.
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
getAllControllers(basePath, token) {
|
|
92
|
+
const store = token.isStore ? token : (0, schema_1.getJsonEntityStore)(token);
|
|
93
|
+
const ctrlPath = (0, schema_1.concatPath)(basePath, schema_1.JsonEntityStore.from(token).path);
|
|
94
|
+
const children = store.get("childrenControllers", []);
|
|
95
|
+
return children
|
|
96
|
+
.reduce((controllers, token) => {
|
|
97
|
+
const childBasePath = (0, schema_1.concatPath)(basePath, store.path);
|
|
98
|
+
return controllers.concat(this.getAllControllers(childBasePath, token));
|
|
99
|
+
}, [])
|
|
100
|
+
.concat([
|
|
101
|
+
{
|
|
102
|
+
route: ctrlPath,
|
|
103
|
+
provider: this.injector.getProvider(token)
|
|
104
|
+
}
|
|
105
|
+
]);
|
|
106
|
+
}
|
|
86
107
|
/**
|
|
87
108
|
* Create controllers from DI
|
|
88
109
|
* @private
|
|
@@ -96,12 +117,12 @@ let Platform = class Platform {
|
|
|
96
117
|
});
|
|
97
118
|
}
|
|
98
119
|
};
|
|
99
|
-
Platform =
|
|
120
|
+
Platform = tslib_1.__decorate([
|
|
100
121
|
(0, di_1.Injectable)({
|
|
101
122
|
scope: di_1.ProviderScope.SINGLETON,
|
|
102
123
|
imports: [PlatformMiddlewaresChain_1.PlatformMiddlewaresChain]
|
|
103
124
|
}),
|
|
104
|
-
|
|
125
|
+
tslib_1.__metadata("design:paramtypes", [di_1.InjectorService, PlatformApplication_1.PlatformApplication])
|
|
105
126
|
], Platform);
|
|
106
127
|
exports.Platform = Platform;
|
|
107
128
|
//# sourceMappingURL=Platform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"Platform.js","sourceRoot":"","sources":["../../../src/services/Platform.ts"],"names":[],"mappings":"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","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {Injectable, InjectorService, ProviderScope, ProviderType, TokenProvider} from \"@tsed/di\";\nimport {concatPath, EndpointMetadata, getJsonEntityStore, getOperationsRoutes, JsonEntityStore} from \"@tsed/schema\";\nimport {buildRouter, createRouter, getRouter} from \"../builder/PlatformControllerBuilder\";\nimport {ControllerProvider} from \"../domain/ControllerProvider\";\nimport {PlatformRouteDetails} from \"../domain/PlatformRouteDetails\";\nimport {Route, RouteController} from \"../interfaces/Route\";\nimport {PlatformApplication} from \"./PlatformApplication\";\nimport {PlatformMiddlewaresChain} from \"./PlatformMiddlewaresChain\";\n\n/**\n * `Platform` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON,\n imports: [PlatformMiddlewaresChain]\n})\nexport class Platform {\n private _routes: PlatformRouteDetails[] = [];\n private _controllers: RouteController[] = [];\n\n constructor(readonly injector: InjectorService, readonly platformApplication: PlatformApplication) {\n this.createRouters();\n }\n\n get app() {\n return this.platformApplication;\n }\n\n get routes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n public addRoutes(routes: Route[]) {\n routes.forEach((routeSettings) => {\n this.addRoute(routeSettings.route, routeSettings.token);\n });\n }\n\n public addRoute(basePath: string, token: TokenProvider) {\n const {injector} = this;\n const provider = injector.getProvider(token) as ControllerProvider;\n\n if (!provider || provider.hasParent()) {\n return;\n }\n\n this._controllers.push(...this.getAllControllers(basePath, token));\n\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(provider.token).path);\n\n this.app.use(ctrlPath, ...[].concat(getRouter(injector, provider).callback()));\n\n this._routes = getOperationsRoutes<EndpointMetadata>(provider.token, {\n withChildren: true,\n basePath\n }).reduce((routes, operationRoute) => {\n if (injector.hasProvider(token)) {\n const provider = injector.getProvider(operationRoute.token) as ControllerProvider;\n const route = new PlatformRouteDetails({\n ...operationRoute,\n provider\n });\n\n routes = routes.concat(route);\n }\n\n return routes;\n }, this._routes);\n\n return this;\n }\n\n /**\n * Get all routes built by TsExpressDecorators and mounted on Express application.\n * @returns {PlatformRouteDetails[]}\n */\n public getRoutes(): PlatformRouteDetails[] {\n return this._routes;\n }\n\n /**\n * Get all controllers mounted on the application.\n * @returns {RouteController[]}\n */\n public getMountedControllers(): RouteController[] {\n return this._controllers;\n }\n\n protected $onInit() {\n this.buildControllers();\n }\n\n /**\n * Create routers from the collected controllers.\n * @private\n */\n private createRouters() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n createRouter(injector, provider);\n });\n }\n\n /**\n * Get all router controllers from the controller token.\n * @private\n */\n private getAllControllers(basePath: string, token: Type<any> | any): RouteController[] {\n const store: JsonEntityStore = token.isStore ? token : getJsonEntityStore(token);\n const ctrlPath = concatPath(basePath, JsonEntityStore.from(token).path);\n const children = store.get<Type[]>(\"childrenControllers\", []);\n\n return children\n .reduce<RouteController[]>((controllers, token) => {\n const childBasePath = concatPath(basePath, store.path);\n return controllers.concat(this.getAllControllers(childBasePath, token));\n }, [])\n .concat([\n {\n route: ctrlPath,\n provider: this.injector.getProvider(token) as ControllerProvider\n }\n ]);\n }\n\n /**\n * Create controllers from DI\n * @private\n */\n private buildControllers() {\n const {injector} = this;\n\n injector.getProviders(ProviderType.CONTROLLER).map((provider: ControllerProvider) => {\n if (!provider.hasParent()) {\n return buildRouter(injector, provider);\n }\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PlatformAdapter = void 0;
|
|
4
|
+
const di_1 = require("@tsed/di");
|
|
5
|
+
const FakeAdapter_1 = require("./FakeAdapter");
|
|
6
|
+
class PlatformAdapter {
|
|
7
|
+
}
|
|
8
|
+
exports.PlatformAdapter = PlatformAdapter;
|
|
9
|
+
(0, di_1.registerProvider)({
|
|
10
|
+
provide: PlatformAdapter,
|
|
11
|
+
deps: [di_1.InjectorService],
|
|
12
|
+
useClass: FakeAdapter_1.FakeAdapter
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=PlatformAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../src/services/PlatformAdapter.ts"],"names":[],"mappings":";;;AACA,iCAAyE;AAIzE,+CAA0C;AAE1C,MAAsB,eAAe;CAoCpC;AApCD,0CAoCC;AAMD,IAAA,qBAAgB,EAAC;IACf,OAAO,EAAE,eAAe;IACxB,IAAI,EAAE,CAAC,oBAAe,CAAC;IACvB,QAAQ,EAAE,yBAAW;CACtB,CAAC,CAAC","sourcesContent":["import {Type} from \"@tsed/core\";\nimport {InjectorService, ProviderOpts, registerProvider} from \"@tsed/di\";\nimport {PlatformMulter, PlatformMulterSettings} from \"../config/interfaces/PlatformMulterSettings\";\nimport {PlatformStaticsOptions} from \"../config/interfaces/PlatformStaticsSettings\";\nimport {RouterOptions} from \"express\";\nimport {FakeAdapter} from \"./FakeAdapter\";\n\nexport abstract class PlatformAdapter<App = TsED.Application, Router = TsED.Router> {\n /**\n * Load providers in top priority\n */\n providers: ProviderOpts[];\n /**\n * Called after the injector instantiation\n */\n onInit?: () => any;\n beforeLoadRoutes?: () => Promise<any>;\n afterLoadRoutes?: () => Promise<any>;\n useRouter?: () => any;\n useContext?: () => any;\n\n abstract app(): {app: App; callback(): any};\n\n abstract router(routerOptions?: Partial<RouterOptions>): {router: Router; callback(): any};\n /**\n * Return the statics middlewares\n * @param endpoint\n * @param options\n */\n abstract statics(endpoint: string, options: PlatformStaticsOptions): any;\n\n /**\n * Return the multipart middleware\n * @param options\n */\n abstract multipart(options: PlatformMulterSettings): PlatformMulter;\n\n /**\n * Return the body parser for the given\n * @param type\n * @param opts\n */\n abstract bodyParser(type: string, opts?: Record<string, any>): any;\n}\n\nexport interface PlatformBuilderSettings<App = TsED.Application, Router = TsED.Router> extends Partial<TsED.Configuration> {\n adapter?: Type<PlatformAdapter<App, Router>>;\n}\n\nregisterProvider({\n provide: PlatformAdapter,\n deps: [InjectorService],\n useClass: FakeAdapter\n});\n"]}
|
|
@@ -1,34 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var PlatformApplication_1;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.PlatformApplication = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
6
5
|
const di_1 = require("@tsed/di");
|
|
7
|
-
const FakeRawDriver_1 = require("./FakeRawDriver");
|
|
8
6
|
const PlatformHandler_1 = require("./PlatformHandler");
|
|
9
7
|
const PlatformRouter_1 = require("./PlatformRouter");
|
|
8
|
+
const PlatformAdapter_1 = require("./PlatformAdapter");
|
|
10
9
|
/**
|
|
11
10
|
* `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
|
|
12
11
|
*
|
|
13
12
|
* @platform
|
|
14
13
|
*/
|
|
15
|
-
let PlatformApplication =
|
|
16
|
-
constructor(platformHandler) {
|
|
17
|
-
super(platformHandler);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return (0, FakeRawDriver_1.createFakeRawDriver)();
|
|
14
|
+
let PlatformApplication = class PlatformApplication extends PlatformRouter_1.PlatformRouter {
|
|
15
|
+
constructor(platformHandler, adapter) {
|
|
16
|
+
super(platformHandler, adapter);
|
|
17
|
+
const { app, callback } = adapter.app();
|
|
18
|
+
this.rawApp = this.raw = app;
|
|
19
|
+
this.callback = callback;
|
|
22
20
|
}
|
|
23
21
|
getApp() {
|
|
24
22
|
return this.raw;
|
|
25
23
|
}
|
|
26
24
|
};
|
|
27
|
-
PlatformApplication =
|
|
25
|
+
PlatformApplication = tslib_1.__decorate([
|
|
28
26
|
(0, di_1.Injectable)({
|
|
29
27
|
scope: di_1.ProviderScope.SINGLETON
|
|
30
28
|
}),
|
|
31
|
-
|
|
29
|
+
tslib_1.__metadata("design:paramtypes", [PlatformHandler_1.PlatformHandler, PlatformAdapter_1.PlatformAdapter])
|
|
32
30
|
], PlatformApplication);
|
|
33
31
|
exports.PlatformApplication = PlatformApplication;
|
|
34
32
|
//# sourceMappingURL=PlatformApplication.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../src/services/PlatformApplication.ts"],"names":[],"mappings":";;;;AAAA,iCAAmD;AACnD,uDAAkD;AAClD,qDAAgD;AAChD,uDAAkD;AASlD;;;;GAIG;AAIH,IAAa,mBAAmB,GAAhC,MAAa,mBAAkE,SAAQ,+BAA2B;IAKhH,YAAY,eAAgC,EAAE,OAAqC;QACjF,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QAChC,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;QAEtC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAC7B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF,CAAA;AAhBY,mBAAmB;IAH/B,IAAA,eAAU,EAAC;QACV,KAAK,EAAE,kBAAa,CAAC,SAAS;KAC/B,CAAC;6CAM6B,iCAAe,EAAW,iCAAe;GAL3D,mBAAmB,CAgB/B;AAhBY,kDAAmB","sourcesContent":["import {Injectable, ProviderScope} from \"@tsed/di\";\nimport {PlatformHandler} from \"./PlatformHandler\";\nimport {PlatformRouter} from \"./PlatformRouter\";\nimport {PlatformAdapter} from \"./PlatformAdapter\";\n\ndeclare global {\n namespace TsED {\n // @ts-ignore\n export interface Application {}\n }\n}\n\n/**\n * `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.\n *\n * @platform\n */\n@Injectable({\n scope: ProviderScope.SINGLETON\n})\nexport class PlatformApplication<App = TsED.Application, Router = TsED.Router> extends PlatformRouter<App, Router> {\n raw: App;\n rawApp: App;\n declare rawRouter: Router;\n\n constructor(platformHandler: PlatformHandler, adapter: PlatformAdapter<App, Router>) {\n super(platformHandler, adapter);\n const {app, callback} = adapter.app();\n\n this.rawApp = this.raw = app;\n this.callback = callback;\n }\n\n getApp(): App {\n return this.raw;\n }\n}\n"]}
|