@tsed/platform-http 8.5.1 → 8.5.3
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/esm/common/fn/adapter.js +15 -5
- package/lib/esm/common/fn/adapter.js.map +1 -1
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js +2 -5
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/common/services/PlatformAdapter.js +14 -9
- package/lib/esm/common/services/PlatformAdapter.js.map +1 -1
- package/lib/esm/common/services/PlatformApplication.js +2 -12
- package/lib/esm/common/services/PlatformApplication.js.map +1 -1
- package/lib/esm/common/services/PlatformHandler.js +2 -3
- package/lib/esm/common/services/PlatformHandler.js.map +1 -1
- package/lib/esm/common/services/PlatformMiddlewaresChain.js +1 -3
- package/lib/esm/common/services/PlatformMiddlewaresChain.js.map +1 -1
- package/lib/esm/common/utils/createInjector.js +2 -28
- package/lib/esm/common/utils/createInjector.js.map +1 -1
- package/lib/types/common/fn/adapter.d.ts +8 -3
- package/lib/types/common/middlewares/PlatformMulterMiddleware.d.ts +0 -2
- package/lib/types/common/services/PlatformAdapter.d.ts +3 -7
- package/lib/types/common/services/PlatformApplication.d.ts +1 -7
- package/lib/types/common/services/PlatformHandler.d.ts +0 -2
- package/lib/types/common/services/PlatformMiddlewaresChain.d.ts +0 -2
- package/package.json +16 -16
- package/src/common/fn/adapter.ts +23 -4
- package/src/common/middlewares/PlatformMulterMiddleware.spec.ts +12 -14
- package/src/common/middlewares/PlatformMulterMiddleware.ts +2 -3
- package/src/common/services/PlatformAdapter.ts +18 -9
- package/src/common/services/PlatformApplication.spec.ts +0 -12
- package/src/common/services/PlatformApplication.ts +2 -19
- package/src/common/services/PlatformHandler.ts +2 -3
- package/src/common/services/PlatformMiddlewaresChain.ts +1 -3
- package/src/common/utils/createInjector.ts +3 -35
|
@@ -1,13 +1,23 @@
|
|
|
1
|
-
import { refValue } from "@tsed/di";
|
|
1
|
+
import { GlobalProviders, injector, refValue } from "@tsed/di";
|
|
2
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
2
3
|
const ADAPTER = "platform.adapter";
|
|
3
4
|
let globalAdapter;
|
|
4
|
-
|
|
5
|
-
* Set the platform adapter
|
|
6
|
-
*/
|
|
7
|
-
export function adapter(adapter) {
|
|
5
|
+
export function adapter(adapter, imports = []) {
|
|
8
6
|
const ref = refValue(ADAPTER);
|
|
9
7
|
if (adapter) {
|
|
10
8
|
globalAdapter ||= adapter;
|
|
9
|
+
imports?.forEach(({ token, useClass }) => {
|
|
10
|
+
const provider = GlobalProviders.get(token);
|
|
11
|
+
if (useClass && provider) {
|
|
12
|
+
provider.useClass = useClass;
|
|
13
|
+
injector().set(token, provider);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
injector()
|
|
17
|
+
.addProvider(PlatformAdapter, {
|
|
18
|
+
useClass: adapter
|
|
19
|
+
})
|
|
20
|
+
.alias(PlatformAdapter, "PlatformAdapter");
|
|
11
21
|
}
|
|
12
22
|
ref.value ||= globalAdapter;
|
|
13
23
|
return ref.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/common/fn/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"adapter.js","sourceRoot":"","sources":["../../../../src/common/fn/adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,eAAe,EAAE,QAAQ,EAAgB,QAAQ,EAAC,MAAM,UAAU,CAAC;AAE3E,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D,MAAM,OAAO,GAAG,kBAAkB,CAAC;AAEnC,IAAI,aAAyC,CAAC;AAU9C,MAAM,UAAU,OAAO,CAAC,OAAoC,EAAE,UAA0B,EAAE;IACxF,MAAM,GAAG,GAAG,QAAQ,CAA6B,OAAO,CAAC,CAAC;IAE1D,IAAI,OAAO,EAAE,CAAC;QACZ,aAAa,KAAK,OAAO,CAAC;QAE1B,OAAO,EAAE,OAAO,CAAC,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAC,EAAE,EAAE;YACrC,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC5C,IAAI,QAAQ,IAAI,QAAQ,EAAE,CAAC;gBACzB,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;gBAC7B,QAAQ,EAAE,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YAClC,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,QAAQ,EAAE;aACP,WAAW,CAAC,eAAe,EAAE;YAC5B,QAAQ,EAAE,OAAO;SAClB,CAAC;aACD,KAAK,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;IAC/C,CAAC;IAED,GAAG,CAAC,KAAK,KAAK,aAAa,CAAC;IAE5B,OAAO,GAAG,CAAC,KAAmC,CAAC;AACjD,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { constant, inject, injectable, ProviderType } from "@tsed/di";
|
|
|
3
3
|
import { BadRequest } from "@tsed/exceptions";
|
|
4
4
|
import { Context } from "@tsed/platform-params";
|
|
5
5
|
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
6
|
-
import {
|
|
6
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
7
7
|
export class MulterException extends BadRequest {
|
|
8
8
|
constructor(er) {
|
|
9
9
|
super(er.message);
|
|
@@ -15,9 +15,6 @@ export class MulterException extends BadRequest {
|
|
|
15
15
|
* @middleware
|
|
16
16
|
*/
|
|
17
17
|
export class PlatformMulterMiddleware {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.app = inject(PlatformApplication);
|
|
20
|
-
}
|
|
21
18
|
async use(ctx) {
|
|
22
19
|
try {
|
|
23
20
|
const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware);
|
|
@@ -29,7 +26,7 @@ export class PlatformMulterMiddleware {
|
|
|
29
26
|
if (settings.storage) {
|
|
30
27
|
delete settings.dest;
|
|
31
28
|
}
|
|
32
|
-
const multer =
|
|
29
|
+
const multer = inject(PlatformAdapter).multipart(settings);
|
|
33
30
|
if (multer) {
|
|
34
31
|
const middleware = multer.fields(this.getFields({ fields }));
|
|
35
32
|
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../../src/common/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAI9C,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../../src/common/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,UAAU,CAAC;AACpE,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAC,OAAO,EAAC,MAAM,uBAAuB,CAAC;AAI9C,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAO/D,MAAM,OAAO,eAAgB,SAAQ,UAAU;IAC7C,YAAY,EAAe;QACzB,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI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AO,EAAE,CAAA;;qCAAM,eAAe;;mDA2BxC;AAOH,UAAU,CAAC,wBAAwB,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { injectable } from "@tsed/di";
|
|
1
|
+
import { configuration, constant, inject, injectable } from "@tsed/di";
|
|
2
|
+
import { $on } from "@tsed/hooks";
|
|
2
3
|
import { application } from "../fn/application.js";
|
|
3
4
|
import { createHttpServer } from "../utils/createHttpServer.js";
|
|
4
5
|
import { createHttpsServer } from "../utils/createHttpsServer.js";
|
|
6
|
+
import { Platform } from "./Platform.js";
|
|
7
|
+
import { PlatformApplication } from "./PlatformApplication.js";
|
|
8
|
+
import { PlatformHandler } from "./PlatformHandler.js";
|
|
5
9
|
export class PlatformAdapter {
|
|
6
10
|
constructor() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
this.app = inject(PlatformApplication);
|
|
12
|
+
const platformApp = inject(PlatformApplication);
|
|
13
|
+
const { app, callback } = this.createApp();
|
|
14
|
+
platformApp.rawApp = app;
|
|
15
|
+
platformApp.rawCallback = callback;
|
|
16
|
+
$on("$afterInvoke", PlatformAdapter, () => {
|
|
17
|
+
configuration().set("PLATFORM_NAME", constant("PLATFORM_NAME") || this.NAME);
|
|
18
|
+
});
|
|
14
19
|
}
|
|
15
20
|
getServers() {
|
|
16
21
|
const app = application();
|
|
@@ -32,5 +37,5 @@ export class PlatformAdapter {
|
|
|
32
37
|
return handler;
|
|
33
38
|
}
|
|
34
39
|
}
|
|
35
|
-
injectable(PlatformAdapter).alias("PlatformAdapter");
|
|
40
|
+
injectable(PlatformAdapter).imports([PlatformApplication, Platform, PlatformHandler]).alias("PlatformAdapter");
|
|
36
41
|
//# sourceMappingURL=PlatformAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"PlatformAdapter.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAC;AAKhC,OAAO,EAAC,WAAW,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,+BAA+B,CAAC;AAEhE,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAC,eAAe,EAAC,MAAM,sBAAsB,CAAC;AAErD,MAAM,OAAgB,eAAe;IAKnC;QAFS,QAAG,GAAG,MAAM,CAA2B,mBAAmB,CAAC,CAAC;QAGnE,MAAM,WAAW,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;QAEhD,MAAM,EAAC,GAAG,EAAE,QAAQ,EAAC,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACzC,WAAW,CAAC,MAAM,GAAG,GAAU,CAAC;QAChC,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC;QAEnC,GAAG,CAAC,cAAc,EAAE,eAAe,EAAE,GAAG,EAAE;YACxC,aAAa,EAAE,CAAC,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;IACL,CAAC;IAED,UAAU;QACR,MAAM,GAAG,GAAG,WAAW,EAAO,CAAC;QAC/B,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,EAAE,iBAAiB,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAU,CAAC;IACxG,CAAC;IAED,MAAM;QACJ,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,gBAAgB;QACd,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAED,eAAe;QACb,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;IAYD;;OAEG;IACH,UAAU,CAAC,OAAiB,EAAE,KAA8B;QAC1D,OAAO,OAAO,CAAC;IACjB,CAAC;CA0BF;AAMD,UAAU,CAAC,eAAe,CAAC,CAAC,OAAO,CAAC,CAAC,mBAAmB,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC"}
|
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { injectable, ProviderScope } from "@tsed/di";
|
|
2
2
|
import { PlatformRouter } from "@tsed/platform-router";
|
|
3
|
-
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
4
3
|
/**
|
|
5
4
|
* `PlatformApplication` is used to provide all routes collected by annotation `@Controller`.
|
|
6
5
|
*
|
|
7
6
|
* @platform
|
|
8
7
|
*/
|
|
9
8
|
export class PlatformApplication extends PlatformRouter {
|
|
10
|
-
|
|
11
|
-
super();
|
|
12
|
-
this.adapter = inject((PlatformAdapter));
|
|
13
|
-
const { app, callback } = this.adapter.createApp();
|
|
14
|
-
this.rawApp = app;
|
|
15
|
-
this.rawCallback = callback;
|
|
16
|
-
}
|
|
9
|
+
rawCallback() { }
|
|
17
10
|
getApp() {
|
|
18
11
|
return this.rawApp;
|
|
19
12
|
}
|
|
20
|
-
multer(options) {
|
|
21
|
-
return this.adapter.multipart(options);
|
|
22
|
-
}
|
|
23
13
|
callback(req, res) {
|
|
24
14
|
if (req && res) {
|
|
25
15
|
return this.callback()(req, res);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformApplication.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"PlatformApplication.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformApplication.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,EAAC,cAAc,EAAC,MAAM,uBAAuB,CAAC;AASrD;;;;GAIG;AACH,MAAM,OAAO,mBAA4C,SAAQ,cAAc;IAG7E,WAAW,KAAS,CAAC;IAErB,MAAM;QACJ,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAID,QAAQ,CAAC,GAAqB,EAAE,GAAoB;QAClD,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;YACf,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACnC,CAAC;QAED,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC5B,CAAC;CACF;AAED,UAAU,CAAC,mBAAmB,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,qBAAqB,CAAC,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { PlatformResponseFilter } from "@tsed/platform-response-filter";
|
|
|
6
6
|
import { PlatformHandlerMetadata, PlatformHandlerType, PlatformRouters, useResponseHandler } from "@tsed/platform-router";
|
|
7
7
|
import { AnyToPromiseWithCtx } from "../domain/AnyToPromiseWithCtx.js";
|
|
8
8
|
import { setResponseHeaders } from "../utils/setResponseHeaders.js";
|
|
9
|
-
import {
|
|
9
|
+
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
10
10
|
import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
|
|
11
11
|
/**
|
|
12
12
|
* Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
|
|
@@ -17,7 +17,6 @@ export class PlatformHandler {
|
|
|
17
17
|
this.responseFilter = inject(PlatformResponseFilter);
|
|
18
18
|
this.platformParams = inject(PlatformParams);
|
|
19
19
|
this.platformExceptions = inject(PlatformExceptions);
|
|
20
|
-
this.platformApplication = inject(PlatformApplication);
|
|
21
20
|
this.platformMiddlewaresChain = inject(PlatformMiddlewaresChain);
|
|
22
21
|
this.platformRouters = inject(PlatformRouters);
|
|
23
22
|
// configure the router module
|
|
@@ -29,7 +28,7 @@ export class PlatformHandler {
|
|
|
29
28
|
})
|
|
30
29
|
.on("alterHandler", (handlerMetadata) => {
|
|
31
30
|
const handler = handlerMetadata.isInjectable() ? this.createHandler(handlerMetadata) : handlerMetadata.handler;
|
|
32
|
-
return
|
|
31
|
+
return inject(PlatformAdapter).mapHandler(handler, handlerMetadata);
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
createHandler(handlerMetadata) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformHandler.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,kBAAkB,EAAE,eAAe,EAAC,MAAM,YAAY,CAAC;AACjF,OAAO,EAAC,MAAM,EAAE,UAAU,EAAY,aAAa,EAAC,MAAM,UAAU,CAAC;AACrE,OAAO,EAAC,kBAAkB,EAAC,MAAM,2BAA2B,CAAC;AAC7D,OAAO,EAAC,cAAc,EAAyB,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAC,sBAAsB,EAAC,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAEL,uBAAuB,EACvB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AAErE,OAAO,EAAC,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IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;oBACnB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,IAAW,CAAC,CAAC;oBACzE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC;QAED,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAED,UAAU,CAAC,eAAe,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { isClass } from "@tsed/core";
|
|
2
|
-
import { constant,
|
|
2
|
+
import { constant, injectable } from "@tsed/di";
|
|
3
3
|
import { ParamTypes } from "@tsed/platform-params";
|
|
4
4
|
import { JsonEntityStore } from "@tsed/schema";
|
|
5
5
|
import { PlatformAcceptMimesMiddleware } from "../middlewares/PlatformAcceptMimesMiddleware.js";
|
|
6
6
|
import { PlatformMulterMiddleware } from "../middlewares/PlatformMulterMiddleware.js";
|
|
7
|
-
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
8
7
|
export class PlatformMiddlewaresChain {
|
|
9
8
|
constructor() {
|
|
10
9
|
this.acceptMimes = constant("acceptMimes", []);
|
|
11
|
-
this.adapter = inject(PlatformAdapter);
|
|
12
10
|
}
|
|
13
11
|
get(handlers, operationRoute) {
|
|
14
12
|
const { ACCEPT_MIMES, FILE } = this.getParamTypes(handlers, operationRoute);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMiddlewaresChain.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformMiddlewaresChain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC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AAK,EAAE,EAAE;YACpB,MAAM,MAAM,GAAG,eAAe,CAAC,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAExD,IAAI,MAAM,CAAC,aAAa,KAAK,QAAQ,EAAE,CAAC;gBACtC,MAAM,EAAC,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAC,GAAG,MAAM,CAAC,aAAa,EAAE,CAAC;gBACtD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC;gBAC1C,UAAU,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ,IAAI,QAAQ,CAAC;gBACtD,UAAU,CAAC,IAAI,GAAG,UAAU,CAAC,IAAI,IAAI,IAAI,CAAC;YAC5C,CAAC;YAED,OAAO,UAAU,CAAC;QACpB,CAAC,EACD;YACE,YAAY,EAAE,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC;YACjD,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC;YAC1C,QAAQ,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC;YACjD,IAAI,EAAE,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,cAAc,CAAC,MAAM,KAAK,KAAK;SAC7E,CACF,CAAC;IACN,CAAC;CACF;AAED,UAAU,CAAC,wBAAwB,CAAC,CAAC"}
|
|
@@ -1,22 +1,9 @@
|
|
|
1
|
-
import { toMap } from "@tsed/core";
|
|
2
1
|
import { injector, setLoggerConfiguration } from "@tsed/di";
|
|
3
2
|
import { $log } from "@tsed/logger";
|
|
4
3
|
import { PlatformConfiguration } from "../config/services/PlatformConfiguration.js";
|
|
5
4
|
import { adapter as $adapter } from "../fn/adapter.js";
|
|
6
|
-
import { Platform } from "../services/Platform.js";
|
|
7
5
|
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
8
|
-
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
9
|
-
import { PlatformHandler } from "../services/PlatformHandler.js";
|
|
10
|
-
import { PlatformRequest } from "../services/PlatformRequest.js";
|
|
11
|
-
import { PlatformResponse } from "../services/PlatformResponse.js";
|
|
12
6
|
$log.name = "TSED";
|
|
13
|
-
const DEFAULT_PROVIDERS = [
|
|
14
|
-
{ token: PlatformHandler },
|
|
15
|
-
{ token: PlatformResponse },
|
|
16
|
-
{ token: PlatformRequest },
|
|
17
|
-
{ token: PlatformApplication },
|
|
18
|
-
{ token: Platform }
|
|
19
|
-
];
|
|
20
7
|
export function createInjector(settings) {
|
|
21
8
|
const inj = injector();
|
|
22
9
|
inj.addProvider(PlatformConfiguration);
|
|
@@ -24,21 +11,8 @@ export function createInjector(settings) {
|
|
|
24
11
|
inj.logger = $log;
|
|
25
12
|
inj.settings.set(settings);
|
|
26
13
|
setLoggerConfiguration();
|
|
27
|
-
|
|
28
|
-
inj
|
|
29
|
-
.addProvider(PlatformAdapter, {
|
|
30
|
-
useClass: adapterToken
|
|
31
|
-
})
|
|
32
|
-
.alias(PlatformAdapter, "PlatformAdapter");
|
|
33
|
-
const adapter = inj.invoke(PlatformAdapter);
|
|
34
|
-
inj.settings.set("PLATFORM_NAME", settings.PLATFORM_NAME || adapter.NAME);
|
|
35
|
-
const instance = inj.get(PlatformAdapter);
|
|
36
|
-
toMap(instance.providers, "token").forEach((provider, token) => {
|
|
37
|
-
inj.addProvider(token, provider);
|
|
38
|
-
});
|
|
39
|
-
DEFAULT_PROVIDERS.filter((provider) => ![PlatformResponse, PlatformRequest].includes(provider.token)).map((provider) => {
|
|
40
|
-
return inj.get(provider.token);
|
|
41
|
-
});
|
|
14
|
+
$adapter(settings.adapter);
|
|
15
|
+
inj.invoke(PlatformAdapter);
|
|
42
16
|
return inj;
|
|
43
17
|
}
|
|
44
18
|
//# sourceMappingURL=createInjector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../../src/common/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"createInjector.js","sourceRoot":"","sources":["../../../../src/common/utils/createInjector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAE,sBAAsB,EAAC,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAElC,OAAO,EAAC,qBAAqB,EAAC,MAAM,6CAA6C,CAAC;AAClF,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC;AAEnB,MAAM,UAAU,cAAc,CAAC,QAAqC;IAClE,MAAM,GAAG,GAAG,QAAQ,EAAE,CAAC;IACvB,GAAG,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAEvC,GAAG,CAAC,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;IACjD,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC;IAClB,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE3B,sBAAsB,EAAE,CAAC;IAEzB,QAAQ,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAE3B,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;IAE5B,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Type } from "@tsed/core";
|
|
2
|
-
import
|
|
2
|
+
import { ProviderOpts } from "@tsed/di";
|
|
3
|
+
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
3
4
|
/**
|
|
4
|
-
* Set the platform adapter
|
|
5
|
+
* Set the platform adapter token and his dependencies
|
|
5
6
|
*/
|
|
6
|
-
export declare function adapter(adapter
|
|
7
|
+
export declare function adapter(adapter: Type<PlatformAdapter<any>>, imports?: ProviderOpts[]): Type<PlatformAdapter<any>>;
|
|
8
|
+
/**
|
|
9
|
+
* Get the platform adapter token
|
|
10
|
+
*/
|
|
11
|
+
export declare function adapter(): Type<PlatformAdapter<any>>;
|
|
@@ -3,7 +3,6 @@ import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
|
3
3
|
import type { MulterError } from "multer";
|
|
4
4
|
import { PlatformMulterField } from "../config/interfaces/PlatformMulterSettings.js";
|
|
5
5
|
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
6
|
-
import { PlatformApplication } from "../services/PlatformApplication.js";
|
|
7
6
|
export interface MulterInputOptions {
|
|
8
7
|
fields: PlatformMulterField[];
|
|
9
8
|
}
|
|
@@ -14,7 +13,6 @@ export declare class MulterException extends BadRequest {
|
|
|
14
13
|
* @middleware
|
|
15
14
|
*/
|
|
16
15
|
export declare class PlatformMulterMiddleware implements MiddlewareMethods {
|
|
17
|
-
protected app: PlatformApplication<any>;
|
|
18
16
|
use(ctx: PlatformContext): Promise<any>;
|
|
19
17
|
protected getFields(conf: MulterInputOptions): {
|
|
20
18
|
name: string;
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
2
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
3
3
|
import { Type } from "@tsed/core";
|
|
4
|
-
import { ProviderOpts } from "@tsed/di";
|
|
5
4
|
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
6
5
|
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
7
6
|
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings.js";
|
|
8
7
|
import { CreateServerReturn } from "../utils/createServer.js";
|
|
9
|
-
import
|
|
8
|
+
import { PlatformApplication } from "./PlatformApplication.js";
|
|
10
9
|
export declare abstract class PlatformAdapter<App = TsED.Application> {
|
|
11
10
|
abstract readonly NAME: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
providers: ProviderOpts[];
|
|
16
|
-
get app(): PlatformApplication<App>;
|
|
11
|
+
readonly app: PlatformApplication<App>;
|
|
12
|
+
constructor();
|
|
17
13
|
getServers(): CreateServerReturn[];
|
|
18
14
|
onInit(): Promise<void> | void;
|
|
19
15
|
beforeLoadRoutes(): Promise<void> | void;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
/// <reference types="multer" />
|
|
2
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
3
2
|
import { IncomingMessage, ServerResponse } from "node:http";
|
|
4
3
|
import { PlatformRouter } from "@tsed/platform-router";
|
|
5
|
-
import { PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
6
|
-
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
7
4
|
declare global {
|
|
8
5
|
namespace TsED {
|
|
9
6
|
interface Application {
|
|
@@ -16,12 +13,9 @@ declare global {
|
|
|
16
13
|
* @platform
|
|
17
14
|
*/
|
|
18
15
|
export declare class PlatformApplication<App = TsED.Application> extends PlatformRouter {
|
|
19
|
-
adapter: PlatformAdapter<App>;
|
|
20
16
|
rawApp: App;
|
|
21
|
-
rawCallback
|
|
22
|
-
constructor();
|
|
17
|
+
rawCallback(): any;
|
|
23
18
|
getApp(): App;
|
|
24
|
-
multer(options: PlatformMulterSettings): import("multer").Multer;
|
|
25
19
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
26
20
|
callback(req: IncomingMessage, res: ServerResponse): any;
|
|
27
21
|
}
|
|
@@ -5,7 +5,6 @@ import { PlatformParams, PlatformParamsCallback } from "@tsed/platform-params";
|
|
|
5
5
|
import { PlatformResponseFilter } from "@tsed/platform-response-filter";
|
|
6
6
|
import { PlatformHandlerMetadata, PlatformRouters } from "@tsed/platform-router";
|
|
7
7
|
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
8
|
-
import { PlatformApplication } from "./PlatformApplication.js";
|
|
9
8
|
import { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
|
|
10
9
|
/**
|
|
11
10
|
* Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
|
|
@@ -15,7 +14,6 @@ export declare class PlatformHandler {
|
|
|
15
14
|
protected responseFilter: PlatformResponseFilter;
|
|
16
15
|
protected platformParams: PlatformParams;
|
|
17
16
|
protected platformExceptions: PlatformExceptions;
|
|
18
|
-
protected platformApplication: PlatformApplication<any>;
|
|
19
17
|
protected platformMiddlewaresChain: PlatformMiddlewaresChain;
|
|
20
18
|
protected platformRouters: PlatformRouters;
|
|
21
19
|
constructor();
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { AlterEndpointHandlersArg } from "@tsed/platform-router";
|
|
2
2
|
import { JsonOperationRoute } from "@tsed/schema";
|
|
3
|
-
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
4
3
|
export declare class PlatformMiddlewaresChain {
|
|
5
4
|
protected acceptMimes: string[];
|
|
6
|
-
protected adapter: PlatformAdapter<any>;
|
|
7
5
|
get(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): AlterEndpointHandlersArg;
|
|
8
6
|
protected hasAcceptMimes(operationRoute: JsonOperationRoute): number;
|
|
9
7
|
protected getParamTypes(middlewares: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/platform-http",
|
|
3
3
|
"description": "A TypeScript Framework on top of Express",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.5.
|
|
5
|
+
"version": "8.5.3",
|
|
6
6
|
"source": "./src/common/index.ts",
|
|
7
7
|
"main": "./lib/esm/common/index.js",
|
|
8
8
|
"module": "./lib/esm/common/index.js",
|
|
@@ -70,28 +70,28 @@
|
|
|
70
70
|
}
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tsed/core": "8.5.
|
|
74
|
-
"@tsed/di": "8.5.
|
|
75
|
-
"@tsed/exceptions": "8.5.
|
|
76
|
-
"@tsed/hooks": "8.5.
|
|
77
|
-
"@tsed/json-mapper": "8.5.
|
|
73
|
+
"@tsed/core": "8.5.3",
|
|
74
|
+
"@tsed/di": "8.5.3",
|
|
75
|
+
"@tsed/exceptions": "8.5.3",
|
|
76
|
+
"@tsed/hooks": "8.5.3",
|
|
77
|
+
"@tsed/json-mapper": "8.5.3",
|
|
78
78
|
"@tsed/logger": "^7.0.1",
|
|
79
|
-
"@tsed/platform-exceptions": "8.5.
|
|
80
|
-
"@tsed/platform-middlewares": "8.5.
|
|
81
|
-
"@tsed/platform-params": "8.5.
|
|
82
|
-
"@tsed/platform-response-filter": "8.5.
|
|
83
|
-
"@tsed/platform-router": "8.5.
|
|
84
|
-
"@tsed/platform-views": "8.5.
|
|
85
|
-
"@tsed/schema": "8.5.
|
|
79
|
+
"@tsed/platform-exceptions": "8.5.3",
|
|
80
|
+
"@tsed/platform-middlewares": "8.5.3",
|
|
81
|
+
"@tsed/platform-params": "8.5.3",
|
|
82
|
+
"@tsed/platform-response-filter": "8.5.3",
|
|
83
|
+
"@tsed/platform-router": "8.5.3",
|
|
84
|
+
"@tsed/platform-views": "8.5.3",
|
|
85
|
+
"@tsed/schema": "8.5.3",
|
|
86
86
|
"@types/json-schema": "7.0.15",
|
|
87
87
|
"accepts": "^1.3.8",
|
|
88
88
|
"tslib": "2.7.0",
|
|
89
89
|
"uuid": "10.0.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@tsed/barrels": "8.5.
|
|
93
|
-
"@tsed/engines": "8.5.
|
|
94
|
-
"@tsed/typescript": "8.5.
|
|
92
|
+
"@tsed/barrels": "8.5.3",
|
|
93
|
+
"@tsed/engines": "8.5.3",
|
|
94
|
+
"@tsed/typescript": "8.5.3",
|
|
95
95
|
"cross-env": "7.0.3",
|
|
96
96
|
"eslint": "9.12.0",
|
|
97
97
|
"typescript": "5.4.5",
|
package/src/common/fn/adapter.ts
CHANGED
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import {Type} from "@tsed/core";
|
|
2
|
-
import {refValue} from "@tsed/di";
|
|
2
|
+
import {GlobalProviders, injector, ProviderOpts, refValue} from "@tsed/di";
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import {PlatformAdapter} from "../services/PlatformAdapter.js";
|
|
5
5
|
|
|
6
6
|
const ADAPTER = "platform.adapter";
|
|
7
7
|
|
|
8
8
|
let globalAdapter: Type<PlatformAdapter<any>>;
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Set the platform adapter
|
|
11
|
+
* Set the platform adapter token and his dependencies
|
|
12
12
|
*/
|
|
13
|
-
export function adapter(adapter
|
|
13
|
+
export function adapter(adapter: Type<PlatformAdapter<any>>, imports?: ProviderOpts[]): Type<PlatformAdapter<any>>;
|
|
14
|
+
/**
|
|
15
|
+
* Get the platform adapter token
|
|
16
|
+
*/
|
|
17
|
+
export function adapter(): Type<PlatformAdapter<any>>;
|
|
18
|
+
export function adapter(adapter?: Type<PlatformAdapter<any>>, imports: ProviderOpts[] = []): Type<PlatformAdapter<any>> {
|
|
14
19
|
const ref = refValue<Type<PlatformAdapter<any>>>(ADAPTER);
|
|
15
20
|
|
|
16
21
|
if (adapter) {
|
|
17
22
|
globalAdapter ||= adapter;
|
|
23
|
+
|
|
24
|
+
imports?.forEach(({token, useClass}) => {
|
|
25
|
+
const provider = GlobalProviders.get(token);
|
|
26
|
+
if (useClass && provider) {
|
|
27
|
+
provider.useClass = useClass;
|
|
28
|
+
injector().set(token, provider);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
injector()
|
|
33
|
+
.addProvider(PlatformAdapter, {
|
|
34
|
+
useClass: adapter
|
|
35
|
+
})
|
|
36
|
+
.alias(PlatformAdapter, "PlatformAdapter");
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
ref.value ||= globalAdapter;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {catchAsyncError} from "@tsed/core";
|
|
2
|
+
import {inject} from "@tsed/di";
|
|
2
3
|
import {Exception} from "@tsed/exceptions";
|
|
3
4
|
import {MulterError} from "multer";
|
|
4
5
|
|
|
@@ -6,6 +7,7 @@ import {PlatformTest} from "../../testing/PlatformTest.js";
|
|
|
6
7
|
import {MulterOptions} from "../decorators/multer/multerOptions.js";
|
|
7
8
|
import {MultipartFile} from "../decorators/multer/multipartFile.js";
|
|
8
9
|
import {EndpointMetadata} from "../domain/EndpointMetadata.js";
|
|
10
|
+
import {PlatformAdapter} from "../services/PlatformAdapter.js";
|
|
9
11
|
import {PlatformApplication} from "../services/PlatformApplication.js";
|
|
10
12
|
import {PlatformMulterMiddleware} from "./PlatformMulterMiddleware.js";
|
|
11
13
|
|
|
@@ -19,20 +21,16 @@ async function build(options = {}) {
|
|
|
19
21
|
const multer = {
|
|
20
22
|
fields: vi.fn().mockReturnValue(multerMiddleware)
|
|
21
23
|
};
|
|
22
|
-
const app = {
|
|
23
|
-
multer: vi.fn().mockReturnValue(multer)
|
|
24
|
-
};
|
|
25
24
|
|
|
26
|
-
const middleware =
|
|
27
|
-
{
|
|
28
|
-
token: PlatformApplication,
|
|
29
|
-
use: app
|
|
30
|
-
}
|
|
31
|
-
]);
|
|
25
|
+
const middleware = inject(PlatformMulterMiddleware);
|
|
32
26
|
const ctx: any = PlatformTest.createRequestContext();
|
|
33
27
|
ctx.endpoint = EndpointMetadata.get(Test, "upload");
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
const adapter = inject(PlatformAdapter);
|
|
30
|
+
|
|
31
|
+
vi.spyOn(adapter, "multipart").mockReturnValue(multer as any);
|
|
32
|
+
|
|
33
|
+
return {middleware, ctx, multer, adapter, multerMiddleware};
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
describe("PlatformMulterMiddleware", () => {
|
|
@@ -45,24 +43,24 @@ describe("PlatformMulterMiddleware", () => {
|
|
|
45
43
|
);
|
|
46
44
|
afterEach(() => PlatformTest.reset());
|
|
47
45
|
it("should create middleware", async () => {
|
|
48
|
-
const {middleware, ctx, multer,
|
|
46
|
+
const {middleware, ctx, multer, adapter, multerMiddleware} = await build({});
|
|
49
47
|
|
|
50
48
|
await middleware.use(ctx);
|
|
51
49
|
|
|
52
|
-
expect(
|
|
50
|
+
expect(adapter.multipart).toHaveBeenCalledWith({
|
|
53
51
|
dest: "/dest"
|
|
54
52
|
});
|
|
55
53
|
expect(multer.fields).toHaveBeenCalledWith([{maxCount: undefined, name: "file1"}]);
|
|
56
54
|
expect(multerMiddleware).toHaveBeenCalledWith(ctx.request.raw, ctx.response.raw);
|
|
57
55
|
});
|
|
58
56
|
it("should create middleware with storage", async () => {
|
|
59
|
-
const {middleware, ctx, multer,
|
|
57
|
+
const {middleware, ctx, multer, adapter, multerMiddleware} = await build({
|
|
60
58
|
storage: "storage"
|
|
61
59
|
});
|
|
62
60
|
|
|
63
61
|
await middleware.use(ctx);
|
|
64
62
|
|
|
65
|
-
expect(
|
|
63
|
+
expect(adapter.multipart).toHaveBeenCalledWith({
|
|
66
64
|
storage: "storage"
|
|
67
65
|
});
|
|
68
66
|
expect(multer.fields).toHaveBeenCalledWith([{maxCount: undefined, name: "file1"}]);
|
|
@@ -6,6 +6,7 @@ import type {MulterError} from "multer";
|
|
|
6
6
|
|
|
7
7
|
import {PlatformMulterField, PlatformMulterSettings} from "../config/interfaces/PlatformMulterSettings.js";
|
|
8
8
|
import {PlatformContext} from "../domain/PlatformContext.js";
|
|
9
|
+
import {PlatformAdapter} from "../services/PlatformAdapter.js";
|
|
9
10
|
import {PlatformApplication} from "../services/PlatformApplication.js";
|
|
10
11
|
|
|
11
12
|
export interface MulterInputOptions {
|
|
@@ -24,8 +25,6 @@ export class MulterException extends BadRequest {
|
|
|
24
25
|
* @middleware
|
|
25
26
|
*/
|
|
26
27
|
export class PlatformMulterMiddleware implements MiddlewareMethods {
|
|
27
|
-
protected app = inject(PlatformApplication);
|
|
28
|
-
|
|
29
28
|
async use(@Context() ctx: PlatformContext) {
|
|
30
29
|
try {
|
|
31
30
|
const {fields, options = {}} = ctx.endpoint.get(PlatformMulterMiddleware);
|
|
@@ -39,7 +38,7 @@ export class PlatformMulterMiddleware implements MiddlewareMethods {
|
|
|
39
38
|
delete settings.dest;
|
|
40
39
|
}
|
|
41
40
|
|
|
42
|
-
const multer =
|
|
41
|
+
const multer = inject(PlatformAdapter).multipart(settings);
|
|
43
42
|
|
|
44
43
|
if (multer) {
|
|
45
44
|
const middleware: any = multer.fields(this.getFields({fields}));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {IncomingMessage, ServerResponse} from "node:http";
|
|
2
2
|
|
|
3
3
|
import {Type} from "@tsed/core";
|
|
4
|
-
import {
|
|
4
|
+
import {configuration, constant, inject, injectable} from "@tsed/di";
|
|
5
|
+
import {$on} from "@tsed/hooks";
|
|
5
6
|
import {PlatformHandlerMetadata, PlatformLayer} from "@tsed/platform-router";
|
|
6
7
|
|
|
7
8
|
import {PlatformMulter, PlatformMulterSettings} from "../config/interfaces/PlatformMulterSettings.js";
|
|
@@ -10,17 +11,25 @@ import {application} from "../fn/application.js";
|
|
|
10
11
|
import {createHttpServer} from "../utils/createHttpServer.js";
|
|
11
12
|
import {createHttpsServer} from "../utils/createHttpsServer.js";
|
|
12
13
|
import {CreateServerReturn} from "../utils/createServer.js";
|
|
13
|
-
import
|
|
14
|
+
import {Platform} from "./Platform.js";
|
|
15
|
+
import {PlatformApplication} from "./PlatformApplication.js";
|
|
16
|
+
import {PlatformHandler} from "./PlatformHandler.js";
|
|
14
17
|
|
|
15
18
|
export abstract class PlatformAdapter<App = TsED.Application> {
|
|
16
19
|
abstract readonly NAME: string;
|
|
17
|
-
/**
|
|
18
|
-
* Load providers in top priority
|
|
19
|
-
*/
|
|
20
|
-
providers: ProviderOpts[] = [];
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
readonly app = inject<PlatformApplication<App>>(PlatformApplication);
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
const platformApp = inject(PlatformApplication);
|
|
25
|
+
|
|
26
|
+
const {app, callback} = this.createApp();
|
|
27
|
+
platformApp.rawApp = app as any;
|
|
28
|
+
platformApp.rawCallback = callback;
|
|
29
|
+
|
|
30
|
+
$on("$afterInvoke", PlatformAdapter, () => {
|
|
31
|
+
configuration().set("PLATFORM_NAME", constant("PLATFORM_NAME") || this.NAME);
|
|
32
|
+
});
|
|
24
33
|
}
|
|
25
34
|
|
|
26
35
|
getServers(): CreateServerReturn[] {
|
|
@@ -87,4 +96,4 @@ export interface PlatformBuilderSettings<App = TsED.Application> extends Partial
|
|
|
87
96
|
adapter?: Type<PlatformAdapter<App>>;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
|
-
injectable(PlatformAdapter).alias("PlatformAdapter");
|
|
99
|
+
injectable(PlatformAdapter).imports([PlatformApplication, Platform, PlatformHandler]).alias("PlatformAdapter");
|
|
@@ -33,7 +33,6 @@ async function getPlatformApp() {
|
|
|
33
33
|
]);
|
|
34
34
|
configuration().logger = {};
|
|
35
35
|
platformApp.rawApp = createDriver() as any;
|
|
36
|
-
vi.spyOn(platformApp, "multer").mockReturnValue({} as never);
|
|
37
36
|
|
|
38
37
|
return {platformApp, platformHandler};
|
|
39
38
|
}
|
|
@@ -63,17 +62,6 @@ describe("PlatformApplication", () => {
|
|
|
63
62
|
platformApp.statics("/", {root: "/root"});
|
|
64
63
|
});
|
|
65
64
|
});
|
|
66
|
-
describe("multer()", () => {
|
|
67
|
-
it("should call statics", async () => {
|
|
68
|
-
// GIVEN
|
|
69
|
-
const {platformApp} = await getPlatformApp();
|
|
70
|
-
|
|
71
|
-
vi.spyOn(console, "warn");
|
|
72
|
-
|
|
73
|
-
// WHEN
|
|
74
|
-
platformApp.multer({});
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
65
|
|
|
78
66
|
describe("callback()", () => {
|
|
79
67
|
it("should return the callback", async () => {
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import {IncomingMessage, ServerResponse} from "node:http";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {injectable, ProviderScope} from "@tsed/di";
|
|
4
4
|
import {PlatformRouter} from "@tsed/platform-router";
|
|
5
5
|
|
|
6
|
-
import {PlatformMulterSettings} from "../config/interfaces/PlatformMulterSettings.js";
|
|
7
|
-
import {PlatformAdapter} from "./PlatformAdapter.js";
|
|
8
|
-
|
|
9
6
|
declare global {
|
|
10
7
|
namespace TsED {
|
|
11
8
|
// @ts-ignore
|
|
@@ -19,28 +16,14 @@ declare global {
|
|
|
19
16
|
* @platform
|
|
20
17
|
*/
|
|
21
18
|
export class PlatformApplication<App = TsED.Application> extends PlatformRouter {
|
|
22
|
-
adapter: PlatformAdapter<App> = inject(PlatformAdapter<App>);
|
|
23
|
-
|
|
24
19
|
rawApp: App;
|
|
25
|
-
rawCallback: () => any;
|
|
26
20
|
|
|
27
|
-
|
|
28
|
-
super();
|
|
29
|
-
|
|
30
|
-
const {app, callback} = this.adapter.createApp();
|
|
31
|
-
|
|
32
|
-
this.rawApp = app;
|
|
33
|
-
this.rawCallback = callback;
|
|
34
|
-
}
|
|
21
|
+
rawCallback(): any {}
|
|
35
22
|
|
|
36
23
|
getApp(): App {
|
|
37
24
|
return this.rawApp;
|
|
38
25
|
}
|
|
39
26
|
|
|
40
|
-
multer(options: PlatformMulterSettings) {
|
|
41
|
-
return this.adapter.multipart(options);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
27
|
callback(): (req: IncomingMessage, res: ServerResponse) => any;
|
|
45
28
|
callback(req: IncomingMessage, res: ServerResponse): any;
|
|
46
29
|
callback(req?: IncomingMessage, res?: ServerResponse) {
|
|
@@ -15,7 +15,7 @@ import {JsonOperationRoute} from "@tsed/schema";
|
|
|
15
15
|
import {AnyToPromiseWithCtx} from "../domain/AnyToPromiseWithCtx.js";
|
|
16
16
|
import {PlatformContext} from "../domain/PlatformContext.js";
|
|
17
17
|
import {setResponseHeaders} from "../utils/setResponseHeaders.js";
|
|
18
|
-
import {
|
|
18
|
+
import {PlatformAdapter} from "./PlatformAdapter.js";
|
|
19
19
|
import {PlatformMiddlewaresChain} from "./PlatformMiddlewaresChain.js";
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -26,7 +26,6 @@ export class PlatformHandler {
|
|
|
26
26
|
protected responseFilter = inject(PlatformResponseFilter);
|
|
27
27
|
protected platformParams = inject(PlatformParams);
|
|
28
28
|
protected platformExceptions = inject(PlatformExceptions);
|
|
29
|
-
protected platformApplication = inject(PlatformApplication);
|
|
30
29
|
protected platformMiddlewaresChain = inject(PlatformMiddlewaresChain);
|
|
31
30
|
protected platformRouters = inject(PlatformRouters);
|
|
32
31
|
|
|
@@ -43,7 +42,7 @@ export class PlatformHandler {
|
|
|
43
42
|
.on("alterHandler", (handlerMetadata: PlatformHandlerMetadata) => {
|
|
44
43
|
const handler = handlerMetadata.isInjectable() ? this.createHandler(handlerMetadata) : handlerMetadata.handler;
|
|
45
44
|
|
|
46
|
-
return
|
|
45
|
+
return inject(PlatformAdapter).mapHandler(handler, handlerMetadata);
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import {isClass} from "@tsed/core";
|
|
2
|
-
import {constant,
|
|
2
|
+
import {constant, injectable} from "@tsed/di";
|
|
3
3
|
import {ParamTypes} from "@tsed/platform-params";
|
|
4
4
|
import {AlterEndpointHandlersArg} from "@tsed/platform-router";
|
|
5
5
|
import {JsonEntityStore, JsonOperationRoute} from "@tsed/schema";
|
|
6
6
|
|
|
7
7
|
import {PlatformAcceptMimesMiddleware} from "../middlewares/PlatformAcceptMimesMiddleware.js";
|
|
8
8
|
import {PlatformMulterMiddleware} from "../middlewares/PlatformMulterMiddleware.js";
|
|
9
|
-
import {PlatformAdapter} from "./PlatformAdapter.js";
|
|
10
9
|
|
|
11
10
|
export class PlatformMiddlewaresChain {
|
|
12
11
|
protected acceptMimes = constant<string[]>("acceptMimes", []);
|
|
13
|
-
protected adapter = inject(PlatformAdapter);
|
|
14
12
|
|
|
15
13
|
get(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): AlterEndpointHandlersArg {
|
|
16
14
|
const {ACCEPT_MIMES, FILE} = this.getParamTypes(handlers, operationRoute);
|
|
@@ -1,26 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {injector, ProviderOpts, setLoggerConfiguration} from "@tsed/di";
|
|
1
|
+
import {injector, setLoggerConfiguration} from "@tsed/di";
|
|
3
2
|
import {$log} from "@tsed/logger";
|
|
4
3
|
|
|
5
4
|
import {PlatformConfiguration} from "../config/services/PlatformConfiguration.js";
|
|
6
5
|
import {adapter as $adapter} from "../fn/adapter.js";
|
|
7
|
-
import {Platform} from "../services/Platform.js";
|
|
8
6
|
import {PlatformAdapter} from "../services/PlatformAdapter.js";
|
|
9
|
-
import {PlatformApplication} from "../services/PlatformApplication.js";
|
|
10
|
-
import {PlatformHandler} from "../services/PlatformHandler.js";
|
|
11
|
-
import {PlatformRequest} from "../services/PlatformRequest.js";
|
|
12
|
-
import {PlatformResponse} from "../services/PlatformResponse.js";
|
|
13
7
|
|
|
14
8
|
$log.name = "TSED";
|
|
15
9
|
|
|
16
|
-
const DEFAULT_PROVIDERS = [
|
|
17
|
-
{token: PlatformHandler},
|
|
18
|
-
{token: PlatformResponse},
|
|
19
|
-
{token: PlatformRequest},
|
|
20
|
-
{token: PlatformApplication},
|
|
21
|
-
{token: Platform}
|
|
22
|
-
];
|
|
23
|
-
|
|
24
10
|
export function createInjector(settings: Partial<TsED.Configuration>) {
|
|
25
11
|
const inj = injector();
|
|
26
12
|
inj.addProvider(PlatformConfiguration);
|
|
@@ -31,27 +17,9 @@ export function createInjector(settings: Partial<TsED.Configuration>) {
|
|
|
31
17
|
|
|
32
18
|
setLoggerConfiguration();
|
|
33
19
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
inj
|
|
37
|
-
.addProvider(PlatformAdapter, {
|
|
38
|
-
useClass: adapterToken
|
|
39
|
-
})
|
|
40
|
-
.alias(PlatformAdapter, "PlatformAdapter");
|
|
41
|
-
|
|
42
|
-
const adapter = inj.invoke(PlatformAdapter);
|
|
43
|
-
|
|
44
|
-
inj.settings.set("PLATFORM_NAME", settings.PLATFORM_NAME || adapter.NAME);
|
|
45
|
-
|
|
46
|
-
const instance = inj.get<PlatformAdapter>(PlatformAdapter)!;
|
|
47
|
-
|
|
48
|
-
toMap<any, ProviderOpts>(instance.providers, "token").forEach((provider, token) => {
|
|
49
|
-
inj.addProvider(token, provider);
|
|
50
|
-
});
|
|
20
|
+
$adapter(settings.adapter);
|
|
51
21
|
|
|
52
|
-
|
|
53
|
-
return inj.get(provider.token);
|
|
54
|
-
});
|
|
22
|
+
inj.invoke(PlatformAdapter);
|
|
55
23
|
|
|
56
24
|
return inj;
|
|
57
25
|
}
|