@tsed/platform-http 8.6.1 → 8.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/common/decorators/multer/multerFileSize.js +4 -5
- package/lib/esm/common/decorators/multer/multerFileSize.js.map +1 -1
- package/lib/esm/common/decorators/multer/multerOptions.js +4 -9
- package/lib/esm/common/decorators/multer/multerOptions.js.map +1 -1
- package/lib/esm/common/decorators/multer/multipartFile.js +4 -30
- package/lib/esm/common/decorators/multer/multipartFile.js.map +1 -1
- package/lib/esm/common/index.js +0 -1
- package/lib/esm/common/index.js.map +1 -1
- package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js +7 -0
- package/lib/esm/common/middlewares/PlatformAcceptMimesMiddleware.js.map +1 -1
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js +3 -50
- package/lib/esm/common/middlewares/PlatformMulterMiddleware.js.map +1 -1
- package/lib/esm/common/services/PlatformAdapter.js +8 -0
- package/lib/esm/common/services/PlatformAdapter.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/types/common/config/interfaces/PlatformMulterSettings.d.ts +17 -14
- package/lib/types/common/decorators/multer/multerFileSize.d.ts +4 -2
- package/lib/types/common/decorators/multer/multerOptions.d.ts +4 -3
- package/lib/types/common/decorators/multer/multipartFile.d.ts +6 -4
- package/lib/types/common/index.d.ts +0 -1
- package/lib/types/common/middlewares/PlatformAcceptMimesMiddleware.d.ts +8 -1
- package/lib/types/common/middlewares/PlatformMulterMiddleware.d.ts +3 -19
- package/lib/types/common/services/PlatformAdapter.d.ts +3 -2
- package/lib/types/common/services/PlatformHandler.d.ts +0 -2
- package/package.json +19 -18
- package/src/common/config/interfaces/PlatformMulterSettings.ts +22 -21
- package/src/common/decorators/multer/multerFileSize.ts +4 -5
- package/src/common/decorators/multer/multerOptions.ts +4 -12
- package/src/common/decorators/multer/multipartFile.ts +6 -43
- package/src/common/index.ts +0 -1
- package/src/common/middlewares/PlatformAcceptMimesMiddleware.ts +11 -1
- package/src/common/middlewares/PlatformMulterMiddleware.ts +3 -59
- package/src/common/services/PlatformAdapter.ts +5 -2
- package/src/common/services/PlatformHandler.ts +2 -3
- package/vitest.config.mts +4 -4
- package/lib/esm/common/services/PlatformMiddlewaresChain.js +0 -43
- package/lib/esm/common/services/PlatformMiddlewaresChain.js.map +0 -1
- package/lib/types/common/services/PlatformMiddlewaresChain.d.ts +0 -13
- package/src/common/decorators/multer/multerFileSize.spec.ts +0 -22
- package/src/common/decorators/multer/multerOptions.spec.ts +0 -21
- package/src/common/decorators/multer/multipartFile.spec.ts +0 -259
- package/src/common/middlewares/PlatformMulterMiddleware.spec.ts +0 -95
- package/src/common/services/PlatformMiddlewaresChain.spec.ts +0 -96
- package/src/common/services/PlatformMiddlewaresChain.ts +0 -53
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MulterFileSize as M } from "@tsed/platform-multer";
|
|
2
2
|
/**
|
|
3
3
|
* Define file size limit.
|
|
4
4
|
*
|
|
5
5
|
* ```typescript
|
|
6
6
|
* import {Post} from "@tsed/schema";
|
|
7
|
-
* import {MulterOptions, MultipartFile} from "@tsed/platform-
|
|
7
|
+
* import {MulterOptions, MultipartFile} from "@tsed/platform-multer";
|
|
8
8
|
* import {Controller} from "@tsed/di";
|
|
9
9
|
* import {Multer} from "@types/multer";
|
|
10
10
|
*
|
|
@@ -24,9 +24,8 @@ import { MulterOptions } from "./multerOptions.js";
|
|
|
24
24
|
* @param fileSize
|
|
25
25
|
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
26
26
|
* @decorator
|
|
27
|
+
* @deprecated use MulterFileSize from @tsed/platform-multer
|
|
27
28
|
* @multer
|
|
28
29
|
*/
|
|
29
|
-
export
|
|
30
|
-
return MulterOptions({ limits: { fileSize } });
|
|
31
|
-
}
|
|
30
|
+
export const MulterFileSize = M;
|
|
32
31
|
//# sourceMappingURL=multerFileSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multerFileSize.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multerFileSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"multerFileSize.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multerFileSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,IAAI,CAAC,EAAC,MAAM,uBAAuB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAa,CAAC,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
|
|
1
|
+
import { MulterOptions as M } from "@tsed/platform-multer";
|
|
3
2
|
/**
|
|
4
3
|
* Define multer option for all MultipartFile
|
|
5
4
|
*
|
|
6
5
|
* ```typescript
|
|
7
|
-
* import {PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/platform-
|
|
6
|
+
* import {PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/platform-multer";
|
|
8
7
|
* import {Controller} from "@tsed/di";
|
|
9
8
|
* import {Post} from "@tsed/schema";
|
|
10
9
|
*
|
|
@@ -40,11 +39,7 @@ import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddle
|
|
|
40
39
|
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
41
40
|
* @decorator
|
|
42
41
|
* @multer
|
|
42
|
+
* @deprecated use MulterOptions from @tsed/platform-multer
|
|
43
43
|
*/
|
|
44
|
-
export
|
|
45
|
-
return (target, propertyKey, descriptor) => {
|
|
46
|
-
StoreMerge(PlatformMulterMiddleware, { options })(target, propertyKey, descriptor);
|
|
47
|
-
return descriptor;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
44
|
+
export const MulterOptions = M;
|
|
50
45
|
//# sourceMappingURL=multerOptions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multerOptions.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"multerOptions.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multerOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,IAAI,CAAC,EAAC,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,CAAC"}
|
|
@@ -1,23 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ParamTypes, UseParam } from "@tsed/platform-params";
|
|
3
|
-
import { InFile } from "@tsed/schema";
|
|
4
|
-
import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware.js";
|
|
5
|
-
function mapOptions(name, maxCount) {
|
|
6
|
-
return {
|
|
7
|
-
fields: [
|
|
8
|
-
{
|
|
9
|
-
name,
|
|
10
|
-
maxCount
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
1
|
+
import { MultipartFile as M } from "@tsed/platform-multer";
|
|
15
2
|
/**
|
|
16
3
|
* Define a parameter as Multipart file.
|
|
17
4
|
*
|
|
18
5
|
* ```typescript
|
|
19
6
|
* import {Post} from "@tsed/schema";
|
|
20
|
-
* import {Controller, MulterOptions, MultipartFile} from "@tsed/platform-
|
|
7
|
+
* import {Controller, MulterOptions, MultipartFile} from "@tsed/platform-multer";
|
|
21
8
|
* import {Controller} from "@tsed/di";
|
|
22
9
|
* import {Multer} from "@types/multer";
|
|
23
10
|
*
|
|
@@ -56,20 +43,7 @@ function mapOptions(name, maxCount) {
|
|
|
56
43
|
* @returns Function
|
|
57
44
|
* @decorator
|
|
58
45
|
* @input
|
|
46
|
+
* @deprecated use MultipartFile from @tsed/platform-multer
|
|
59
47
|
*/
|
|
60
|
-
export
|
|
61
|
-
return (...args) => {
|
|
62
|
-
const [target, propertyKey, index] = args;
|
|
63
|
-
const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
|
|
64
|
-
name = (typeof name === "object" ? undefined : name);
|
|
65
|
-
const expression = [name, !multiple && "0"].filter(Boolean).join(".");
|
|
66
|
-
const decorators = useDecorators(InFile(name), useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))), UseParam({
|
|
67
|
-
paramType: ParamTypes.FILES,
|
|
68
|
-
dataPath: "$ctx.request.files",
|
|
69
|
-
expression,
|
|
70
|
-
useValidation: true
|
|
71
|
-
}));
|
|
72
|
-
decorators(...args);
|
|
73
|
-
};
|
|
74
|
-
}
|
|
48
|
+
export const MultipartFile = M;
|
|
75
49
|
//# sourceMappingURL=multipartFile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multipartFile.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../../src/common/decorators/multer/multipartFile.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,aAAa,IAAI,CAAC,EAAC,MAAM,uBAAuB,CAAC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,CAAC,MAAM,aAAa,GAAa,CAAC,CAAC"}
|
package/lib/esm/common/index.js
CHANGED
|
@@ -44,7 +44,6 @@ export * from "./services/Platform.js";
|
|
|
44
44
|
export * from "./services/PlatformAdapter.js";
|
|
45
45
|
export * from "./services/PlatformApplication.js";
|
|
46
46
|
export * from "./services/PlatformHandler.js";
|
|
47
|
-
export * from "./services/PlatformMiddlewaresChain.js";
|
|
48
47
|
export * from "./services/PlatformRequest.js";
|
|
49
48
|
export * from "./services/PlatformResponse.js";
|
|
50
49
|
export * from "./utils/closeServer.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,8BAA8B,CAAC;AAC7C,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,iCAAiC,CAAC;AAChD,cAAc,kCAAkC,CAAC;AACjD,cAAc,iCAAiC,CAAC;AAChD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kCAAkC,CAAC;AACjD,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,sCAAsC,CAAC;AACrD,cAAc,qCAAqC,CAAC;AACpD,cAAc,uBAAuB,CAAC;AACtC,cAAc,gDAAgD,CAA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,CAAC;AACtC,cAAc,gDAAgD,CAAC;AAC/D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mCAAmC,CAAC;AAClD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,+BAA+B,CAAC"}
|
|
@@ -11,6 +11,13 @@ export class PlatformAcceptMimesMiddleware {
|
|
|
11
11
|
constructor() {
|
|
12
12
|
this.acceptMimes = constant("acceptMimes", []);
|
|
13
13
|
}
|
|
14
|
+
$alterEndpointHandlers(handlers, operationRoute) {
|
|
15
|
+
const hasAcceptMimes = operationRoute.endpoint.acceptMimes.length || this.acceptMimes.length;
|
|
16
|
+
return {
|
|
17
|
+
...handlers,
|
|
18
|
+
before: [hasAcceptMimes && PlatformAcceptMimesMiddleware, ...handlers.before].filter(Boolean)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
14
21
|
use(ctx) {
|
|
15
22
|
const { endpoint, request } = ctx;
|
|
16
23
|
const mimes = uniq((endpoint?.get("acceptMimes") || []).concat(this.acceptMimes));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformAcceptMimesMiddleware.js","sourceRoot":"","sources":["../../../../src/common/middlewares/PlatformAcceptMimesMiddleware.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,YAAY,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AM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,MAAM,IAAI,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AARQ;IAAK,WAAA,OAAO,EAAE,CAAA;;;;wDAOpB;AAGH,UAAU,CAAC,6BAA6B,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -1,53 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { constant, inject, injectable, ProviderType } from "@tsed/di";
|
|
3
|
-
import { BadRequest } from "@tsed/exceptions";
|
|
4
|
-
import { Context } from "@tsed/platform-params";
|
|
5
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
6
|
-
import { PlatformAdapter } from "../services/PlatformAdapter.js";
|
|
7
|
-
export class MulterException extends BadRequest {
|
|
8
|
-
constructor(er) {
|
|
9
|
-
super(er.message);
|
|
10
|
-
this.origin = er;
|
|
11
|
-
this.name = er.code;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
1
|
+
import { PlatformMulterMiddleware as M } from "@tsed/platform-multer";
|
|
14
2
|
/**
|
|
15
|
-
* @
|
|
3
|
+
* @deprecated Since version 8.5. Use PlatformMulterMiddleware from @tsed/platform-multer package
|
|
16
4
|
*/
|
|
17
|
-
export
|
|
18
|
-
async use(ctx) {
|
|
19
|
-
try {
|
|
20
|
-
const { fields, options = {} } = ctx.endpoint.get(PlatformMulterMiddleware);
|
|
21
|
-
const settings = {
|
|
22
|
-
...constant("multer", {}),
|
|
23
|
-
...options
|
|
24
|
-
};
|
|
25
|
-
/* istanbul ignore next */
|
|
26
|
-
if (settings.storage) {
|
|
27
|
-
delete settings.dest;
|
|
28
|
-
}
|
|
29
|
-
const multer = inject(PlatformAdapter).multipart(settings);
|
|
30
|
-
if (multer) {
|
|
31
|
-
const middleware = multer.fields(this.getFields({ fields }));
|
|
32
|
-
return await middleware(ctx.getRequest(), ctx.getResponse());
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
catch (er) {
|
|
36
|
-
if (er.code) {
|
|
37
|
-
throw new MulterException(er);
|
|
38
|
-
}
|
|
39
|
-
throw er;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
getFields(conf) {
|
|
43
|
-
return conf.fields.map(({ name, maxCount }) => ({ name, maxCount }));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
__decorate([
|
|
47
|
-
__param(0, Context()),
|
|
48
|
-
__metadata("design:type", Function),
|
|
49
|
-
__metadata("design:paramtypes", [PlatformContext]),
|
|
50
|
-
__metadata("design:returntype", Promise)
|
|
51
|
-
], PlatformMulterMiddleware.prototype, "use", null);
|
|
52
|
-
injectable(PlatformMulterMiddleware).type(ProviderType.MIDDLEWARE).priority(-10);
|
|
5
|
+
export const PlatformMulterMiddleware = M;
|
|
53
6
|
//# sourceMappingURL=PlatformMulterMiddleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../../src/common/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PlatformMulterMiddleware.js","sourceRoot":"","sources":["../../../../src/common/middlewares/PlatformMulterMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,wBAAwB,IAAI,CAAC,EAAC,MAAM,uBAAuB,CAAC;AAEpE;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAa,CAAC,CAAC"}
|
|
@@ -36,6 +36,14 @@ export class PlatformAdapter {
|
|
|
36
36
|
mapHandler(handler, layer) {
|
|
37
37
|
return handler;
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Return the multipart middleware
|
|
41
|
+
* @param options
|
|
42
|
+
* @deprecated use inject("MULTER_MODULE")?.get(options) instead
|
|
43
|
+
*/
|
|
44
|
+
multipart(options) {
|
|
45
|
+
return inject(Symbol.for("MULTER_MODULE"))?.get(options);
|
|
46
|
+
}
|
|
39
47
|
}
|
|
40
48
|
injectable(PlatformAdapter).imports([PlatformApplication, Platform, PlatformHandler]).alias("PlatformAdapter");
|
|
41
49
|
//# sourceMappingURL=PlatformAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
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,IAA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
|
|
1
1
|
import { AnyToPromiseStatus, catchAsyncError } from "@tsed/core";
|
|
2
2
|
import { inject, injectable, ProviderScope } from "@tsed/di";
|
|
3
|
+
import { $alter } from "@tsed/hooks";
|
|
3
4
|
import { PlatformExceptions } from "@tsed/platform-exceptions";
|
|
4
5
|
import { PlatformParams } from "@tsed/platform-params";
|
|
5
6
|
import { PlatformResponseFilter } from "@tsed/platform-response-filter";
|
|
@@ -7,7 +8,6 @@ import { PlatformHandlerMetadata, PlatformHandlerType, PlatformRouters, useRespo
|
|
|
7
8
|
import { AnyToPromiseWithCtx } from "../domain/AnyToPromiseWithCtx.js";
|
|
8
9
|
import { setResponseHeaders } from "../utils/setResponseHeaders.js";
|
|
9
10
|
import { PlatformAdapter } from "./PlatformAdapter.js";
|
|
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...).
|
|
13
13
|
* @platform
|
|
@@ -17,12 +17,11 @@ export class PlatformHandler {
|
|
|
17
17
|
this.responseFilter = inject(PlatformResponseFilter);
|
|
18
18
|
this.platformParams = inject(PlatformParams);
|
|
19
19
|
this.platformExceptions = inject(PlatformExceptions);
|
|
20
|
-
this.platformMiddlewaresChain = inject(PlatformMiddlewaresChain);
|
|
21
20
|
this.platformRouters = inject(PlatformRouters);
|
|
22
21
|
// configure the router module
|
|
23
22
|
this.platformRouters.hooks
|
|
24
23
|
.on("alterEndpointHandlers", (handlers, operationRoute) => {
|
|
25
|
-
handlers =
|
|
24
|
+
handlers = $alter("$alterEndpointHandlers", handlers, [operationRoute]);
|
|
26
25
|
handlers.after.push(useResponseHandler(this.flush.bind(this)));
|
|
27
26
|
return handlers;
|
|
28
27
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformHandler.js","sourceRoot":"","sources":["../../../../src/common/services/PlatformHandler.ts"],"names":[],"mappings":"AAAA,O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AI,CAAC;QACnB,CAAC;QAED,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAElB,oDAAoD;QACpD,IAAI,IAAI,CAAC,eAAe,CAAC,UAAU,EAAE,EAAE,CAAC;YACtC,kBAAkB,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK,CAAC,IAAqB;QAC/B,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,KAAK,GAAG,MAAM,eAAe,CAAC,KAAK,IAAI,EAAE;gBAC5C,MAAM,EAAC,QAAQ,EAAC,GAAG,IAAI,CAAC;gBAExB,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,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type PlatformMulterFile =
|
|
14
|
-
|
|
1
|
+
import { PlatformMulter as M1, PlatformMulterField as M4, PlatformMulterFile as M3, PlatformMulterSettings as M2 } from "@tsed/platform-multer";
|
|
2
|
+
/**
|
|
3
|
+
* @deprecated Since v8.5. Use PlatformMulter from @tsed/platform-multer instead.
|
|
4
|
+
*/
|
|
5
|
+
export type PlatformMulter = M1;
|
|
6
|
+
/**
|
|
7
|
+
* @deprecated Since v8.5. Use PlatformMulterSettings from @tsed/platform-multer instead.
|
|
8
|
+
*/
|
|
9
|
+
export type PlatformMulterSettings = M2;
|
|
10
|
+
/**
|
|
11
|
+
* @deprecated Since v8.5. Use PlatformMulterFile from @tsed/platform-multer instead.
|
|
12
|
+
*/
|
|
13
|
+
export type PlatformMulterFile = M3;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Since v8.5. Use PlatformMulterField from @tsed/platform-multer instead.
|
|
16
|
+
*/
|
|
17
|
+
export type PlatformMulterField = M4;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { MulterFileSize as M } from "@tsed/platform-multer";
|
|
1
2
|
/**
|
|
2
3
|
* Define file size limit.
|
|
3
4
|
*
|
|
4
5
|
* ```typescript
|
|
5
6
|
* import {Post} from "@tsed/schema";
|
|
6
|
-
* import {MulterOptions, MultipartFile} from "@tsed/platform-
|
|
7
|
+
* import {MulterOptions, MultipartFile} from "@tsed/platform-multer";
|
|
7
8
|
* import {Controller} from "@tsed/di";
|
|
8
9
|
* import {Multer} from "@types/multer";
|
|
9
10
|
*
|
|
@@ -23,6 +24,7 @@
|
|
|
23
24
|
* @param fileSize
|
|
24
25
|
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
25
26
|
* @decorator
|
|
27
|
+
* @deprecated use MulterFileSize from @tsed/platform-multer
|
|
26
28
|
* @multer
|
|
27
29
|
*/
|
|
28
|
-
export declare
|
|
30
|
+
export declare const MulterFileSize: typeof M;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MulterOptions as M } from "@tsed/platform-multer";
|
|
2
2
|
/**
|
|
3
3
|
* Define multer option for all MultipartFile
|
|
4
4
|
*
|
|
5
5
|
* ```typescript
|
|
6
|
-
* import {PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/platform-
|
|
6
|
+
* import {PlatformMulterFile, MultipartFile, MulterOptions} from "@tsed/platform-multer";
|
|
7
7
|
* import {Controller} from "@tsed/di";
|
|
8
8
|
* import {Post} from "@tsed/schema";
|
|
9
9
|
*
|
|
@@ -39,5 +39,6 @@ import { PlatformMulterSettings } from "../../config/interfaces/PlatformMulterSe
|
|
|
39
39
|
* @returns {(target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor}
|
|
40
40
|
* @decorator
|
|
41
41
|
* @multer
|
|
42
|
+
* @deprecated use MulterOptions from @tsed/platform-multer
|
|
42
43
|
*/
|
|
43
|
-
export declare
|
|
44
|
+
export declare const MulterOptions: typeof M;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { MultipartFile as MType } from "@tsed/platform-multer";
|
|
2
|
+
import { MultipartFile as M } from "@tsed/platform-multer";
|
|
2
3
|
/**
|
|
3
4
|
* Define a parameter as Multipart file.
|
|
4
5
|
*
|
|
5
6
|
* ```typescript
|
|
6
7
|
* import {Post} from "@tsed/schema";
|
|
7
|
-
* import {Controller, MulterOptions, MultipartFile} from "@tsed/platform-
|
|
8
|
+
* import {Controller, MulterOptions, MultipartFile} from "@tsed/platform-multer";
|
|
8
9
|
* import {Controller} from "@tsed/di";
|
|
9
10
|
* import {Multer} from "@types/multer";
|
|
10
11
|
*
|
|
@@ -43,6 +44,7 @@ import { PlatformMulterFile } from "../../config/interfaces/PlatformMulterSettin
|
|
|
43
44
|
* @returns Function
|
|
44
45
|
* @decorator
|
|
45
46
|
* @input
|
|
47
|
+
* @deprecated use MultipartFile from @tsed/platform-multer
|
|
46
48
|
*/
|
|
47
|
-
export declare
|
|
48
|
-
export type MultipartFile =
|
|
49
|
+
export declare const MultipartFile: typeof M;
|
|
50
|
+
export type MultipartFile = MType;
|
|
@@ -44,7 +44,6 @@ export * from "./services/Platform.js";
|
|
|
44
44
|
export * from "./services/PlatformAdapter.js";
|
|
45
45
|
export * from "./services/PlatformApplication.js";
|
|
46
46
|
export * from "./services/PlatformHandler.js";
|
|
47
|
-
export * from "./services/PlatformMiddlewaresChain.js";
|
|
48
47
|
export * from "./services/PlatformRequest.js";
|
|
49
48
|
export * from "./services/PlatformResponse.js";
|
|
50
49
|
export * from "./utils/closeServer.js";
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
2
2
|
import { Context } from "@tsed/platform-params";
|
|
3
|
+
import type { AlterEndpointHandlersArg } from "@tsed/platform-router";
|
|
4
|
+
import type { JsonOperationRoute } from "@tsed/schema";
|
|
3
5
|
/**
|
|
4
6
|
* @middleware
|
|
5
7
|
* @platform
|
|
6
8
|
*/
|
|
7
9
|
export declare class PlatformAcceptMimesMiddleware implements MiddlewareMethods {
|
|
8
|
-
acceptMimes: string[];
|
|
10
|
+
protected acceptMimes: string[];
|
|
11
|
+
$alterEndpointHandlers(handlers: AlterEndpointHandlersArg, operationRoute: JsonOperationRoute): {
|
|
12
|
+
before: any[];
|
|
13
|
+
endpoint: import("@tsed/schema").JsonMethodStore;
|
|
14
|
+
after: (Function | import("@tsed/core").Type<any>)[];
|
|
15
|
+
};
|
|
9
16
|
use(ctx: Context): void;
|
|
10
17
|
}
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { MiddlewareMethods } from "@tsed/platform-middlewares";
|
|
3
|
-
import type { MulterError } from "multer";
|
|
4
|
-
import { PlatformMulterField } from "../config/interfaces/PlatformMulterSettings.js";
|
|
5
|
-
import { PlatformContext } from "../domain/PlatformContext.js";
|
|
6
|
-
export interface MulterInputOptions {
|
|
7
|
-
fields: PlatformMulterField[];
|
|
8
|
-
}
|
|
9
|
-
export declare class MulterException extends BadRequest {
|
|
10
|
-
constructor(er: MulterError);
|
|
11
|
-
}
|
|
1
|
+
import { PlatformMulterMiddleware as M } from "@tsed/platform-multer";
|
|
12
2
|
/**
|
|
13
|
-
* @
|
|
3
|
+
* @deprecated Since version 8.5. Use PlatformMulterMiddleware from @tsed/platform-multer package
|
|
14
4
|
*/
|
|
15
|
-
export declare
|
|
16
|
-
use(ctx: PlatformContext): Promise<any>;
|
|
17
|
-
protected getFields(conf: MulterInputOptions): {
|
|
18
|
-
name: string;
|
|
19
|
-
maxCount: number | undefined;
|
|
20
|
-
}[];
|
|
21
|
-
}
|
|
5
|
+
export declare const PlatformMulterMiddleware: typeof M;
|
|
@@ -1,8 +1,8 @@
|
|
|
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 type { PlatformMulter, PlatformMulterSettings } from "@tsed/platform-multer";
|
|
4
5
|
import { PlatformHandlerMetadata, PlatformLayer } from "@tsed/platform-router";
|
|
5
|
-
import { PlatformMulter, PlatformMulterSettings } from "../config/interfaces/PlatformMulterSettings.js";
|
|
6
6
|
import { PlatformStaticsOptions } from "../config/interfaces/PlatformStaticsSettings.js";
|
|
7
7
|
import { CreateServerReturn } from "../utils/createServer.js";
|
|
8
8
|
import { PlatformApplication } from "./PlatformApplication.js";
|
|
@@ -42,8 +42,9 @@ export declare abstract class PlatformAdapter<App = TsED.Application> {
|
|
|
42
42
|
/**
|
|
43
43
|
* Return the multipart middleware
|
|
44
44
|
* @param options
|
|
45
|
+
* @deprecated use inject("MULTER_MODULE")?.get(options) instead
|
|
45
46
|
*/
|
|
46
|
-
|
|
47
|
+
multipart(options: PlatformMulterSettings): PlatformMulter;
|
|
47
48
|
/**
|
|
48
49
|
* Return the body parser for the given
|
|
49
50
|
* @param type
|
|
@@ -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 { PlatformMiddlewaresChain } from "./PlatformMiddlewaresChain.js";
|
|
9
8
|
/**
|
|
10
9
|
* Platform Handler abstraction layer. Wrap original class method to a pure platform handler (Express, Koa, etc...).
|
|
11
10
|
* @platform
|
|
@@ -14,7 +13,6 @@ export declare class PlatformHandler {
|
|
|
14
13
|
protected responseFilter: PlatformResponseFilter;
|
|
15
14
|
protected platformParams: PlatformParams;
|
|
16
15
|
protected platformExceptions: PlatformExceptions;
|
|
17
|
-
protected platformMiddlewaresChain: PlatformMiddlewaresChain;
|
|
18
16
|
protected platformRouters: PlatformRouters;
|
|
19
17
|
constructor();
|
|
20
18
|
createHandler(handlerMetadata: PlatformHandlerMetadata): any;
|
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
|
+
"version": "8.7.0",
|
|
6
6
|
"source": "./src/common/index.ts",
|
|
7
7
|
"main": "./lib/esm/common/index.js",
|
|
8
8
|
"module": "./lib/esm/common/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "yarn barrels && yarn build:ts",
|
|
26
26
|
"barrels": "barrels",
|
|
27
27
|
"test": "vitest run",
|
|
28
|
-
"build:ts": "tsc --build tsconfig.json",
|
|
28
|
+
"build:ts": "tsc --build tsconfig.esm.json",
|
|
29
29
|
"test:ci": "vitest run --coverage.thresholds.autoUpdate=true"
|
|
30
30
|
},
|
|
31
31
|
"keywords": [
|
|
@@ -70,32 +70,33 @@
|
|
|
70
70
|
}
|
|
71
71
|
],
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@tsed/core": "8.
|
|
74
|
-
"@tsed/di": "8.
|
|
75
|
-
"@tsed/exceptions": "8.
|
|
76
|
-
"@tsed/hooks": "8.
|
|
77
|
-
"@tsed/json-mapper": "8.
|
|
73
|
+
"@tsed/core": "8.7.0",
|
|
74
|
+
"@tsed/di": "8.7.0",
|
|
75
|
+
"@tsed/exceptions": "8.7.0",
|
|
76
|
+
"@tsed/hooks": "8.7.0",
|
|
77
|
+
"@tsed/json-mapper": "8.7.0",
|
|
78
78
|
"@tsed/logger": "^7.0.1",
|
|
79
|
-
"@tsed/platform-exceptions": "8.
|
|
80
|
-
"@tsed/platform-middlewares": "8.
|
|
81
|
-
"@tsed/platform-
|
|
82
|
-
"@tsed/platform-
|
|
83
|
-
"@tsed/platform-
|
|
84
|
-
"@tsed/platform-
|
|
85
|
-
"@tsed/
|
|
79
|
+
"@tsed/platform-exceptions": "8.7.0",
|
|
80
|
+
"@tsed/platform-middlewares": "8.7.0",
|
|
81
|
+
"@tsed/platform-multer": "8.7.0",
|
|
82
|
+
"@tsed/platform-params": "8.7.0",
|
|
83
|
+
"@tsed/platform-response-filter": "8.7.0",
|
|
84
|
+
"@tsed/platform-router": "8.7.0",
|
|
85
|
+
"@tsed/platform-views": "8.7.0",
|
|
86
|
+
"@tsed/schema": "8.7.0",
|
|
86
87
|
"@types/json-schema": "7.0.15",
|
|
87
88
|
"accepts": "^1.3.8",
|
|
88
89
|
"tslib": "2.7.0",
|
|
89
90
|
"uuid": "10.0.0"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
|
-
"@tsed/barrels": "8.
|
|
93
|
-
"@tsed/engines": "8.
|
|
94
|
-
"@tsed/typescript": "8.
|
|
93
|
+
"@tsed/barrels": "8.7.0",
|
|
94
|
+
"@tsed/engines": "8.7.0",
|
|
95
|
+
"@tsed/typescript": "8.7.0",
|
|
95
96
|
"cross-env": "7.0.3",
|
|
96
97
|
"eslint": "9.12.0",
|
|
97
98
|
"typescript": "5.4.5",
|
|
98
|
-
"vitest": "
|
|
99
|
+
"vitest": "3.0.9"
|
|
99
100
|
},
|
|
100
101
|
"peerDependencies": {
|
|
101
102
|
"@tsed/logger": ">=7.0.1"
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import {
|
|
2
|
+
PlatformMulter as M1,
|
|
3
|
+
PlatformMulterField as M4,
|
|
4
|
+
PlatformMulterFile as M3,
|
|
5
|
+
PlatformMulterSettings as M2
|
|
6
|
+
} from "@tsed/platform-multer";
|
|
7
|
+
/**
|
|
8
|
+
* @deprecated Since v8.5. Use PlatformMulter from @tsed/platform-multer instead.
|
|
9
|
+
*/
|
|
10
|
+
export type PlatformMulter = M1;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated Since v8.5. Use PlatformMulterSettings from @tsed/platform-multer instead.
|
|
13
|
+
*/
|
|
14
|
+
export type PlatformMulterSettings = M2;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated Since v8.5. Use PlatformMulterFile from @tsed/platform-multer instead.
|
|
17
|
+
*/
|
|
18
|
+
export type PlatformMulterFile = M3;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Since v8.5. Use PlatformMulterField from @tsed/platform-multer instead.
|
|
21
|
+
*/
|
|
22
|
+
export type PlatformMulterField = M4;
|