@tsed/common 6.92.0 → 6.95.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.
@@ -65,7 +65,7 @@ function MultipartFile(name, maxCount) {
65
65
  const multiple = core_1.Metadata.getParamTypes(target, propertyKey)[index] === Array;
66
66
  name = (typeof name === "object" ? undefined : name);
67
67
  const expression = [name, !multiple && "0"].filter(Boolean).join(".");
68
- const decorators = (0, core_1.useDecorators)((0, core_1.useMethodDecorators)((0, schema_1.Returns)(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), (0, schema_1.Consumes)("multipart/form-data"), (0, core_1.StoreMerge)(PlatformMulterMiddleware_1.PlatformMulterMiddleware, mapOptions(name, maxCount))), (0, platform_params_1.UseParam)({
68
+ const decorators = (0, core_1.useDecorators)((0, schema_1.InFile)(name), (0, core_1.useMethodDecorators)((0, core_1.StoreMerge)(PlatformMulterMiddleware_1.PlatformMulterMiddleware, mapOptions(name, maxCount))), (0, platform_params_1.UseParam)({
69
69
  paramType: platform_params_1.ParamTypes.FILES,
70
70
  dataPath: "$ctx.request.files",
71
71
  expression,
@@ -1 +1 @@
1
- {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":";;;AAAA,qCAAyG;AACzG,2DAA2D;AAC3D,yCAA+C;AAE/C,yFAAwG;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,SAAgB,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,eAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,IAAA,oBAAa,EAC9B,IAAA,0BAAmB,EACjB,IAAA,gBAAO,EAAC,GAAG,CAAC,CAAC,WAAW,CACtB,+KAA+K,CAChL,EACD,IAAA,iBAAQ,EAAC,qBAAqB,CAAC,EAC/B,IAAA,iBAAU,EAAC,mDAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CACjE,EACD,IAAA,0BAAQ,EAAC;YACP,SAAS,EAAE,4BAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC;AA3BD,sCA2BC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n useMethodDecorators(\n Returns(400).Description(\n `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`\n ),\n Consumes(\"multipart/form-data\"),\n StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))\n ),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
1
+ {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":";;;AAAA,q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reMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, InFile, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
@@ -1,11 +1,6 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { ParamMetadata } from "@tsed/platform-params";
3
- import { JsonEntityStoreOptions, JsonMethodStore, JsonOperation } from "@tsed/schema";
4
- export interface EndpointConstructorOptions extends JsonEntityStoreOptions {
5
- beforeMiddlewares?: Function[];
6
- middlewares?: Function[];
7
- afterMiddlewares?: Function[];
8
- }
3
+ import { JsonMethodStore } from "@tsed/schema";
9
4
  export interface EndpointViewOptions {
10
5
  path: string;
11
6
  options: any;
@@ -30,11 +25,7 @@ export interface EndpointRedirectOptions {
30
25
  * }
31
26
  *
32
27
  */
33
- export declare class EndpointMetadata extends JsonMethodStore implements EndpointConstructorOptions {
34
- beforeMiddlewares: any[];
35
- middlewares: any[];
36
- afterMiddlewares: any[];
37
- constructor(options: EndpointConstructorOptions);
28
+ export declare class EndpointMetadata extends JsonMethodStore {
38
29
  get targetName(): string;
39
30
  get params(): ParamMetadata[];
40
31
  get view(): EndpointViewOptions;
@@ -48,7 +39,7 @@ export declare class EndpointMetadata extends JsonMethodStore implements Endpoin
48
39
  * @param descriptor
49
40
  */
50
41
  static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata;
51
- addOperationPath(method: string, path: string | RegExp, options?: any): JsonOperation;
42
+ addOperationPath(method: string, path: string | RegExp, options?: any): import("@tsed/schema").JsonOperation;
52
43
  /**
53
44
  * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
54
45
  *
@@ -56,21 +47,4 @@ export declare class EndpointMetadata extends JsonMethodStore implements Endpoin
56
47
  * @returns {any}
57
48
  */
58
49
  get<T = any>(key: any): T;
59
- /**
60
- * Append middlewares to the beforeMiddlewares list.
61
- * @param args
62
- * @returns {EndpointMetadata}
63
- */
64
- before(args: Function[]): this;
65
- /**
66
- * Append middlewares to the afterMiddlewares list.
67
- * @param args
68
- * @returns {EndpointMetadata}
69
- */
70
- after(args: Function[]): this;
71
- /**
72
- * Store all arguments collected via Annotation.
73
- * @param args
74
- */
75
- use(args: Function[]): this;
76
50
  }
@@ -21,20 +21,6 @@ const schema_1 = require("@tsed/schema");
21
21
  *
22
22
  */
23
23
  let EndpointMetadata = class EndpointMetadata extends schema_1.JsonMethodStore {
24
- constructor(options) {
25
- super({
26
- store: core_1.Store.fromMethod(options.target, options.propertyKey),
27
- descriptor: (0, core_1.descriptorOf)(options.target, options.propertyKey),
28
- ...options
29
- });
30
- this.beforeMiddlewares = [];
31
- this.middlewares = [];
32
- this.afterMiddlewares = [];
33
- const { beforeMiddlewares = [], middlewares = [], afterMiddlewares = [] } = options;
34
- this.after(afterMiddlewares);
35
- this.before(beforeMiddlewares);
36
- this.use(middlewares);
37
- }
38
24
  get targetName() {
39
25
  return (0, core_1.nameOf)(this.token);
40
26
  }
@@ -76,36 +62,9 @@ let EndpointMetadata = class EndpointMetadata extends schema_1.JsonMethodStore {
76
62
  const ctrlValue = core_1.Store.from(this.target).get(key);
77
63
  return (0, core_1.deepMerge)(ctrlValue, this.store.get(key));
78
64
  }
79
- /**
80
- * Append middlewares to the beforeMiddlewares list.
81
- * @param args
82
- * @returns {EndpointMetadata}
83
- */
84
- before(args) {
85
- this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(core_1.isFunction);
86
- return this;
87
- }
88
- /**
89
- * Append middlewares to the afterMiddlewares list.
90
- * @param args
91
- * @returns {EndpointMetadata}
92
- */
93
- after(args) {
94
- this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(core_1.isFunction);
95
- return this;
96
- }
97
- /**
98
- * Store all arguments collected via Annotation.
99
- * @param args
100
- */
101
- use(args) {
102
- this.middlewares = this.middlewares.concat(args).filter(core_1.isFunction);
103
- return this;
104
- }
105
65
  };
106
66
  EndpointMetadata = (0, tslib_1.__decorate)([
107
- (0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.METHOD),
108
- (0, tslib_1.__metadata)("design:paramtypes", [Object])
67
+ (0, schema_1.JsonEntityComponent)(core_1.DecoratorTypes.METHOD)
109
68
  ], EndpointMetadata);
110
69
  exports.EndpointMetadata = EndpointMetadata;
111
70
  //# sourceMappingURL=EndpointMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;;AAAA,qCAAiH;AAEjH,yCAA0H;AAkB1H;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,wBAAe;IAKnD,YAAY,OAAmC;QAC7C,KAAK,CAAC;YACJ,KAAK,EAAE,YAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC7D,UAAU,EAAE,IAAA,mBAAY,EAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC9D,GAAG,OAAO;SACX,CAAC,CAAC;QATE,sBAAiB,GAAU,EAAE,CAAC;QAC9B,gBAAW,GAAU,EAAE,CAAC;QACxB,qBAAgB,GAAU,EAAE,CAAC;QASlC,MAAM,EAAC,iBAAiB,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAC,GAAG,OAAO,CAAC;QAElF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAA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,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAEhF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAgB;QAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,IAAgB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,iBAAU,CAAC,CAAC;QAEpE,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtGY,gBAAgB;IAD5B,IAAA,4BAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;;GAC9B,gBAAgB,CAsG5B;AAtGY,4CAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isFunction, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonEntityStoreOptions, JsonMethodStore, JsonOperation} from \"@tsed/schema\";\n\nexport interface EndpointConstructorOptions extends JsonEntityStoreOptions {\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n}\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore implements EndpointConstructorOptions {\n public beforeMiddlewares: any[] = [];\n public middlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n\n constructor(options: EndpointConstructorOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";;;;AAAA,qCAAqG;AAErG,yCAAmF;AAYnF;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,wBAAe;IACnD,IAAI,UAAU;QACZ,OAAO,IAAA,aAAM,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAwB,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,IAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAW,aAAa,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,WAAW,CAAC,KAAe;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAA+B;QACzF,UAAU,GAAG,UAAU,IAAI,IAAA,mBAAY,EAAC,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;QAE1E,OAAO,wBAAe,CAAC,IAAI,CAAmB,IAAA,kBAAW,EAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,IAAqB,EAAE,UAAe,EAAE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,GAAQ;QACnB,MAAM,SAAS,GAAG,YAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnD,OAAO,IAAA,gBAAS,EAAI,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AApDY,gBAAgB;IAD5B,IAAA,4BAAmB,EAAC,qBAAc,CAAC,MAAM,CAAC;GAC9B,gBAAgB,CAoD5B;AApDY,4CAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonMethodStore} from \"@tsed/schema\";\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore {\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import { Metadata, StoreMerge, useDecorators, useMethodDecorators } from "@tsed/core";
2
2
  import { ParamTypes, UseParam } from "@tsed/platform-params";
3
- import { Consumes, Returns } from "@tsed/schema";
3
+ import { InFile } from "@tsed/schema";
4
4
  import { PlatformMulterMiddleware } from "../../middlewares/PlatformMulterMiddleware";
5
5
  function mapOptions(name, maxCount) {
6
6
  return {
@@ -62,7 +62,7 @@ export function MultipartFile(name, maxCount) {
62
62
  const multiple = Metadata.getParamTypes(target, propertyKey)[index] === Array;
63
63
  name = (typeof name === "object" ? undefined : name);
64
64
  const expression = [name, !multiple && "0"].filter(Boolean).join(".");
65
- const decorators = useDecorators(useMethodDecorators(Returns(400).Description(`<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`), Consumes("multipart/form-data"), StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))), UseParam({
65
+ const decorators = useDecorators(InFile(name), useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))), UseParam({
66
66
  paramType: ParamTypes.FILES,
67
67
  dataPath: "$ctx.request.files",
68
68
  expression,
@@ -1 +1 @@
1
- {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACzG,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAqB,wBAAwB,EAAC,MAAM,4CAA4C,CAAC;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,aAAa,CAC9B,mBAAmB,CACjB,OAAO,CAAC,GAAG,CAAC,CAAC,WAAW,CACtB,+KAA+K,CAChL,EACD,QAAQ,CAAC,qBAAqB,CAAC,EAC/B,UAAU,CAAC,wBAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CACjE,EACD,QAAQ,CAAC;YACP,SAAS,EAAE,UAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n useMethodDecorators(\n Returns(400).Description(\n `<File too long | Too many parts | Too many files | Field name too long | Field value too long | Too many fields | Unexpected field> [fieldName] Example: File too long file1`\n ),\n Consumes(\"multipart/form-data\"),\n StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))\n ),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
1
+ {"version":3,"file":"multipartFile.js","sourceRoot":"","sources":["../../../../src/decorators/multer/multipartFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,mBAAmB,EAAC,MAAM,YAAY,CAAC;AACzG,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAW,MAAM,EAAU,MAAM,cAAc,CAAC;AAEvD,OAAO,EAAqB,wBAAwB,EAAC,MAAM,4CAA4C,CAAC;AAExG,SAAS,UAAU,CAAC,IAAY,EAAE,QAA4B;IAC5D,OAAO;QACL,MAAM,EAAE;YACN;gBACE,IAAI;gBACJ,QAAQ;aACT;SACF;KACF,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,QAAiB;IAC3D,OAAO,CAAC,GAAG,IAAyB,EAAQ,EAAE;QAC5C,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;QAC1C,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,KAAe,CAAC,KAAK,KAAK,CAAC;QAExF,IAAI,GAAG,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAE,CAAC;QAEtD,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,CAAC,QAAQ,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEtE,MAAM,UAAU,GAAG,aAAa,CAC9B,MAAM,CAAC,IAAI,CAAC,EACZ,mBAAmB,CAAC,UAAU,CAAC,wBAAwB,EAAE,UAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,EACrF,QAAQ,CAAC;YACP,SAAS,EAAE,UAAU,CAAC,KAAK;YAC3B,QAAQ,EAAE,oBAAoB;YAC9B,UAAU;YACV,aAAa,EAAE,IAAI;SACpB,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,GAAG,IAAI,CAAC,CAAC;IACtB,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import {DecoratorParameters, Metadata, StoreMerge, useDecorators, useMethodDecorators} from \"@tsed/core\";\nimport {ParamTypes, UseParam} from \"@tsed/platform-params\";\nimport {Consumes, InFile, Returns} from \"@tsed/schema\";\nimport {PlatformMulterFile} from \"../../config/interfaces/PlatformMulterSettings\";\nimport {MulterInputOptions, PlatformMulterMiddleware} from \"../../middlewares/PlatformMulterMiddleware\";\n\nfunction mapOptions(name: string, maxCount: number | undefined): MulterInputOptions {\n return {\n fields: [\n {\n name,\n maxCount\n }\n ]\n };\n}\n\n/**\n * Define a parameter as Multipart file.\n *\n * ```typescript\n * import {Controller, Post} from \"@tsed/common\";\n * import {MulterOptions, MultipartFile} from \"@tsed/common\";\n * import {Multer} from \"@types/multer\";\n *\n * type MulterFile = Express.Multer.File;\n *\n * @Controller('/')\n * class MyCtrl {\n * @Post('/file')\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile) {\n *\n * }\n *\n * @Post('/file2')\n * @MulterOptions({dest: \"/other-dir\"})\n * private uploadFile(@MultipartFile(\"file1\") file: MulterFile, @MultipartFile(\"file2\") file2: MulterFile) {\n *\n * }\n *\n * @Post('/files')\n * private uploadFile(@MultipartFile(\"file1\") files: MulterFile[]) {\n *\n * }\n * }\n * ```\n *\n * > See the tutorial on the [multer configuration](/tutorials/multer.md).\n *\n * @param name\n * @param maxCount\n * @returns Function\n * @decorator\n * @input\n */\nexport function MultipartFile(name: string, maxCount?: number): ParameterDecorator {\n return (...args: DecoratorParameters): void => {\n const [target, propertyKey, index] = args;\n const multiple = Metadata.getParamTypes(target, propertyKey)[index as number] === Array;\n\n name = (typeof name === \"object\" ? undefined : name)!;\n\n const expression = [name, !multiple && \"0\"].filter(Boolean).join(\".\");\n\n const decorators = useDecorators(\n InFile(name),\n useMethodDecorators(StoreMerge(PlatformMulterMiddleware, mapOptions(name, maxCount))),\n UseParam({\n paramType: ParamTypes.FILES,\n dataPath: \"$ctx.request.files\",\n expression,\n useValidation: true\n })\n );\n\n decorators(...args);\n };\n}\n\nexport type MultipartFile = PlatformMulterFile;\n"]}
@@ -1,5 +1,5 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import { DecoratorTypes, deepMerge, descriptorOf, isFunction, nameOf, prototypeOf, Store } from "@tsed/core";
1
+ import { __decorate } from "tslib";
2
+ import { DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store } from "@tsed/core";
3
3
  import { JsonEntityComponent, JsonEntityStore, JsonMethodStore } from "@tsed/schema";
4
4
  /**
5
5
  * EndpointMetadata contains metadata about a controller and his method.
@@ -18,20 +18,6 @@ import { JsonEntityComponent, JsonEntityStore, JsonMethodStore } from "@tsed/sch
18
18
  *
19
19
  */
20
20
  let EndpointMetadata = class EndpointMetadata extends JsonMethodStore {
21
- constructor(options) {
22
- super({
23
- store: Store.fromMethod(options.target, options.propertyKey),
24
- descriptor: descriptorOf(options.target, options.propertyKey),
25
- ...options
26
- });
27
- this.beforeMiddlewares = [];
28
- this.middlewares = [];
29
- this.afterMiddlewares = [];
30
- const { beforeMiddlewares = [], middlewares = [], afterMiddlewares = [] } = options;
31
- this.after(afterMiddlewares);
32
- this.before(beforeMiddlewares);
33
- this.use(middlewares);
34
- }
35
21
  get targetName() {
36
22
  return nameOf(this.token);
37
23
  }
@@ -73,36 +59,9 @@ let EndpointMetadata = class EndpointMetadata extends JsonMethodStore {
73
59
  const ctrlValue = Store.from(this.target).get(key);
74
60
  return deepMerge(ctrlValue, this.store.get(key));
75
61
  }
76
- /**
77
- * Append middlewares to the beforeMiddlewares list.
78
- * @param args
79
- * @returns {EndpointMetadata}
80
- */
81
- before(args) {
82
- this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);
83
- return this;
84
- }
85
- /**
86
- * Append middlewares to the afterMiddlewares list.
87
- * @param args
88
- * @returns {EndpointMetadata}
89
- */
90
- after(args) {
91
- this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);
92
- return this;
93
- }
94
- /**
95
- * Store all arguments collected via Annotation.
96
- * @param args
97
- */
98
- use(args) {
99
- this.middlewares = this.middlewares.concat(args).filter(isFunction);
100
- return this;
101
- }
102
62
  };
103
63
  EndpointMetadata = __decorate([
104
- JsonEntityComponent(DecoratorTypes.METHOD),
105
- __metadata("design:paramtypes", [Object])
64
+ JsonEntityComponent(DecoratorTypes.METHOD)
106
65
  ], EndpointMetadata);
107
66
  export { EndpointMetadata };
108
67
  //# sourceMappingURL=EndpointMetadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAEjH,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAA0B,eAAe,EAAgB,MAAM,cAAc,CAAC;AAkB1H;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,eAAe;IAKnD,YAAY,OAAmC;QAC7C,KAAK,CAAC;YACJ,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC7D,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,WAAY,CAAC;YAC9D,GAAG,OAAO;SACX,CAAC,CAAC;QATE,sBAAiB,GAAU,EAAE,CAAC;QAC9B,gBAAW,GAAU,EAAE,CAAC;QACxB,qBAAgB,GAAU,EAAE,CAAC;QASlC,MAAM,EAAC,iBAAiB,GAAG,EAAE,EAAE,WAAW,GAAG,EAAE,EAAE,gBAAgB,GAAG,EAAE,EAAC,GAAG,OAAO,CAAC;QAElF,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC/B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACxB,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK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CAAC,CAAC;QAEhF,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,IAAgB;QAC3B,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAE9E,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;OAGG;IACI,GAAG,CAAC,IAAgB;QACzB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAEpE,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAtGY,gBAAgB;IAD5B,mBAAmB,CAAC,cAAc,CAAC,MAAM,CAAC;;GAC9B,gBAAgB,CAsG5B;SAtGY,gBAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, isFunction, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonEntityStoreOptions, JsonMethodStore, JsonOperation} from \"@tsed/schema\";\n\nexport interface EndpointConstructorOptions extends JsonEntityStoreOptions {\n beforeMiddlewares?: Function[];\n middlewares?: Function[];\n afterMiddlewares?: Function[];\n}\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore implements EndpointConstructorOptions {\n public beforeMiddlewares: any[] = [];\n public middlewares: any[] = [];\n public afterMiddlewares: any[] = [];\n\n constructor(options: EndpointConstructorOptions) {\n super({\n store: Store.fromMethod(options.target, options.propertyKey!),\n descriptor: descriptorOf(options.target, options.propertyKey!),\n ...options\n });\n\n const {beforeMiddlewares = [], middlewares = [], afterMiddlewares = []} = options;\n\n this.after(afterMiddlewares);\n this.before(beforeMiddlewares);\n this.use(middlewares);\n }\n\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n\n /**\n * Append middlewares to the beforeMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public before(args: Function[]): this {\n this.beforeMiddlewares = this.beforeMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Append middlewares to the afterMiddlewares list.\n * @param args\n * @returns {EndpointMetadata}\n */\n public after(args: Function[]): this {\n this.afterMiddlewares = this.afterMiddlewares.concat(args).filter(isFunction);\n\n return this;\n }\n\n /**\n * Store all arguments collected via Annotation.\n * @param args\n */\n public use(args: Function[]) {\n this.middlewares = this.middlewares.concat(args).filter(isFunction);\n\n return this;\n }\n}\n"]}
1
+ {"version":3,"file":"EndpointMetadata.js","sourceRoot":"","sources":["../../../src/domain/EndpointMetadata.ts"],"names":[],"mappings":";AAAA,OAAO,EAAC,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AAErG,OAAO,EAAC,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAYnF;;;;;;;;;;;;;;;GAeG;AAEH,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,eAAe;IACnD,IAAI,UAAU;QACZ,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,UAA6B,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAwB,CAAC;IACvD,CAAC;IAED,IAAI,IAAI,CAAC,IAAyB;QAChC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAW,aAAa,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,WAAW,CAAC,KAAe;QAC7B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,GAAG,CAAC,MAAiB,EAAE,WAA4B,EAAE,UAA+B;QACzF,UAAU,GAAG,UAAU,IAAI,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC;QAE1E,OAAO,eAAe,CAAC,IAAI,CAAmB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9F,CAAC;IAED,gBAAgB,CAAC,MAAc,EAAE,IAAqB,EAAE,UAAe,EAAE;QACvE,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAU,GAAQ;QACnB,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnD,OAAO,SAAS,CAAI,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;CACF,CAAA;AApDY,gBAAgB;IAD5B,mBAAmB,CAAC,cAAc,CAAC,MAAM,CAAC;GAC9B,gBAAgB,CAoD5B;SApDY,gBAAgB","sourcesContent":["import {DecoratorTypes, deepMerge, descriptorOf, nameOf, prototypeOf, Store, Type} from \"@tsed/core\";\nimport {ParamMetadata} from \"@tsed/platform-params\";\nimport {JsonEntityComponent, JsonEntityStore, JsonMethodStore} from \"@tsed/schema\";\n\nexport interface EndpointViewOptions {\n path: string;\n options: any;\n}\n\nexport interface EndpointRedirectOptions {\n status: number | undefined;\n url: string;\n}\n\n/**\n * EndpointMetadata contains metadata about a controller and his method.\n * Each annotation (@Get, @Body...) attached to a method are stored in a endpoint.\n * EndpointMetadata convert this metadata to an array which contain arguments to call an Express method.\n *\n * Example :\n *\n * @Controller(\"/my-path\")\n * provide MyClass {\n *\n * @Get(\"/\")\n * @Authenticated()\n * public myMethod(){}\n * }\n *\n */\n@JsonEntityComponent(DecoratorTypes.METHOD)\nexport class EndpointMetadata extends JsonMethodStore {\n get targetName(): string {\n return nameOf(this.token);\n }\n\n get params(): ParamMetadata[] {\n return this.parameters as ParamMetadata[];\n }\n\n get view(): EndpointViewOptions {\n return this.store.get(\"view\") as EndpointViewOptions;\n }\n\n set view(view: EndpointViewOptions) {\n this.store.set(\"view\", view);\n }\n\n get acceptMimes(): string[] {\n return this.store.get<string[]>(\"acceptMimes\", []);\n }\n\n set acceptMimes(mimes: string[]) {\n this.store.set(\"acceptMimes\", mimes);\n }\n\n /**\n * Get an endpoint.\n * @param target\n * @param propertyKey\n * @param descriptor\n */\n static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata {\n descriptor = descriptor || descriptorOf(prototypeOf(target), propertyKey);\n\n return JsonEntityStore.from<EndpointMetadata>(prototypeOf(target), propertyKey, descriptor);\n }\n\n addOperationPath(method: string, path: string | RegExp, options: any = {}) {\n return this.operation.addOperationPath(method, path, options);\n }\n\n /**\n * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.\n *\n * @param key\n * @returns {any}\n */\n get<T = any>(key: any): T {\n const ctrlValue = Store.from(this.target).get(key);\n\n return deepMerge<T>(ctrlValue, this.store.get(key));\n }\n}\n"]}
@@ -1,11 +1,6 @@
1
1
  import { Type } from "@tsed/core";
2
2
  import { ParamMetadata } from "@tsed/platform-params";
3
- import { JsonEntityStoreOptions, JsonMethodStore, JsonOperation } from "@tsed/schema";
4
- export interface EndpointConstructorOptions extends JsonEntityStoreOptions {
5
- beforeMiddlewares?: Function[];
6
- middlewares?: Function[];
7
- afterMiddlewares?: Function[];
8
- }
3
+ import { JsonMethodStore } from "@tsed/schema";
9
4
  export interface EndpointViewOptions {
10
5
  path: string;
11
6
  options: any;
@@ -30,11 +25,7 @@ export interface EndpointRedirectOptions {
30
25
  * }
31
26
  *
32
27
  */
33
- export declare class EndpointMetadata extends JsonMethodStore implements EndpointConstructorOptions {
34
- beforeMiddlewares: any[];
35
- middlewares: any[];
36
- afterMiddlewares: any[];
37
- constructor(options: EndpointConstructorOptions);
28
+ export declare class EndpointMetadata extends JsonMethodStore {
38
29
  get targetName(): string;
39
30
  get params(): ParamMetadata[];
40
31
  get view(): EndpointViewOptions;
@@ -48,7 +39,7 @@ export declare class EndpointMetadata extends JsonMethodStore implements Endpoin
48
39
  * @param descriptor
49
40
  */
50
41
  static get(target: Type<any>, propertyKey: string | symbol, descriptor?: PropertyDescriptor): EndpointMetadata;
51
- addOperationPath(method: string, path: string | RegExp, options?: any): JsonOperation;
42
+ addOperationPath(method: string, path: string | RegExp, options?: any): import("@tsed/schema").JsonOperation;
52
43
  /**
53
44
  * Find the a value at the controller level. Let this value be extended or overridden by the endpoint itself.
54
45
  *
@@ -56,21 +47,4 @@ export declare class EndpointMetadata extends JsonMethodStore implements Endpoin
56
47
  * @returns {any}
57
48
  */
58
49
  get<T = any>(key: any): T;
59
- /**
60
- * Append middlewares to the beforeMiddlewares list.
61
- * @param args
62
- * @returns {EndpointMetadata}
63
- */
64
- before(args: Function[]): this;
65
- /**
66
- * Append middlewares to the afterMiddlewares list.
67
- * @param args
68
- * @returns {EndpointMetadata}
69
- */
70
- after(args: Function[]): this;
71
- /**
72
- * Store all arguments collected via Annotation.
73
- * @param args
74
- */
75
- use(args: Function[]): this;
76
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsed/common",
3
- "version": "6.92.0",
3
+ "version": "6.95.0",
4
4
  "description": "A TypeScript Framework on top of Express",
5
5
  "private": false,
6
6
  "source": "./src/index.ts",
@@ -59,22 +59,22 @@
59
59
  }
60
60
  ],
61
61
  "dependencies": {
62
- "@tsed/components-scan": "6.92.0",
63
- "@tsed/core": "6.92.0",
64
- "@tsed/di": "6.92.0",
65
- "@tsed/exceptions": "6.92.0",
66
- "@tsed/json-mapper": "6.92.0",
62
+ "@tsed/components-scan": "6.95.0",
63
+ "@tsed/core": "6.95.0",
64
+ "@tsed/di": "6.95.0",
65
+ "@tsed/exceptions": "6.95.0",
66
+ "@tsed/json-mapper": "6.95.0",
67
67
  "@tsed/logger": "^6.0.0",
68
68
  "@tsed/logger-file": "^6.0.0",
69
- "@tsed/perf": "6.92.0",
70
- "@tsed/platform-cache": "6.92.0",
71
- "@tsed/platform-exceptions": "6.92.0",
72
- "@tsed/platform-log-middleware": "6.92.0",
73
- "@tsed/platform-middlewares": "6.92.0",
74
- "@tsed/platform-params": "6.92.0",
75
- "@tsed/platform-response-filter": "6.92.0",
76
- "@tsed/platform-views": "6.92.0",
77
- "@tsed/schema": "6.92.0",
69
+ "@tsed/perf": "6.95.0",
70
+ "@tsed/platform-cache": "6.95.0",
71
+ "@tsed/platform-exceptions": "6.95.0",
72
+ "@tsed/platform-log-middleware": "6.95.0",
73
+ "@tsed/platform-middlewares": "6.95.0",
74
+ "@tsed/platform-params": "6.95.0",
75
+ "@tsed/platform-response-filter": "6.95.0",
76
+ "@tsed/platform-views": "6.95.0",
77
+ "@tsed/schema": "6.95.0",
78
78
  "@types/json-schema": "7.0.7",
79
79
  "on-finished": "2.3.0",
80
80
  "tslib": "2.2.0",