@zenofolio/hyper-decor 1.0.4 → 1.0.7
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/README.md +64 -1
- package/debug.txt +1 -0
- package/dist/__internals/constants.d.ts +5 -1
- package/dist/__internals/constants.js +5 -1
- package/dist/__internals/creators/request.creator.d.ts +2 -3
- package/dist/__internals/creators/request.creator.js +5 -3
- package/dist/__internals/creators/routes.creator.d.ts +2 -3
- package/dist/__internals/creators/routes.creator.js +5 -3
- package/dist/__internals/decorator-base.js +47 -11
- package/dist/__internals/helpers/imports.helper.d.ts +8 -0
- package/dist/__internals/helpers/imports.helper.js +92 -0
- package/dist/__internals/helpers/lifecycle.helper.d.ts +3 -0
- package/dist/__internals/helpers/lifecycle.helper.js +25 -0
- package/dist/__internals/helpers/merge-metadata.js +16 -20
- package/dist/__internals/helpers/prepare.helper.d.ts +11 -0
- package/dist/__internals/helpers/prepare.helper.js +348 -0
- package/dist/__internals/helpers/tree.helper.d.ts +36 -0
- package/dist/__internals/helpers/tree.helper.js +81 -0
- package/dist/__internals/stores/service.store.d.ts +1 -0
- package/dist/__internals/{transform/pass.transfrom.js → stores/service.store.js} +2 -0
- package/dist/__internals/transform/middleware.transform.d.ts +3 -0
- package/dist/__internals/transform/middleware.transform.js +19 -0
- package/dist/__internals/transform/role.transform.js +8 -5
- package/dist/__internals/transform/scope.transfrom.d.ts +5 -7
- package/dist/__internals/transform/scope.transfrom.js +52 -38
- package/dist/__internals/transform/transform.registry.d.ts +33 -0
- package/dist/__internals/transform/transform.registry.js +59 -0
- package/dist/__internals/utils/function.util.d.ts +1 -4
- package/dist/__internals/utils/function.util.js +22 -10
- package/dist/common/bootstrap.js +4 -0
- package/dist/common/helpers/index.d.ts +1 -0
- package/dist/common/helpers/index.js +1 -0
- package/dist/common/helpers/scopes.d.ts +3 -3
- package/dist/common/helpers/scopes.js +7 -8
- package/dist/common/helpers/state.d.ts +17 -0
- package/dist/common/helpers/state.js +44 -0
- package/dist/common/message-bus.d.ts +11 -0
- package/dist/common/message-bus.js +51 -0
- package/dist/common/transport.d.ts +9 -0
- package/dist/common/transport.js +46 -0
- package/dist/decorators/File.d.ts +1 -1
- package/dist/decorators/Http.d.ts +20 -13
- package/dist/decorators/Http.js +77 -31
- package/dist/decorators/HyperApp.d.ts +0 -4
- package/dist/decorators/HyperApp.js +16 -182
- package/dist/decorators/HyperController.js +2 -1
- package/dist/decorators/HyperService.d.ts +15 -0
- package/dist/decorators/HyperService.js +29 -0
- package/dist/decorators/Messaging.d.ts +10 -0
- package/dist/decorators/Messaging.js +22 -0
- package/dist/decorators/Middleware.d.ts +5 -4
- package/dist/decorators/Middleware.js +33 -19
- package/dist/decorators/Output.d.ts +9 -0
- package/dist/decorators/Output.js +18 -0
- package/dist/decorators/Pass.d.ts +6 -3
- package/dist/decorators/Pass.js +6 -3
- package/dist/decorators/Role.js +5 -5
- package/dist/decorators/Routes.d.ts +14 -13
- package/dist/decorators/Scope.js +3 -3
- package/dist/decorators/Transform.d.ts +14 -0
- package/dist/decorators/Transform.js +18 -0
- package/dist/decorators/index.d.ts +3 -0
- package/dist/decorators/index.js +3 -0
- package/dist/decorators/types.d.ts +45 -10
- package/dist/decorators/types.js +4 -0
- package/dist/extension.js +11 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/lib/openapi/collectors/class.collector.d.ts +9 -0
- package/dist/lib/openapi/collectors/class.collector.js +67 -0
- package/dist/lib/openapi/collectors/index.d.ts +4 -0
- package/dist/lib/openapi/collectors/index.js +20 -0
- package/dist/lib/openapi/collectors/method.collector.d.ts +2 -0
- package/dist/lib/openapi/collectors/method.collector.js +68 -0
- package/dist/lib/openapi/collectors/param.collector.d.ts +2 -0
- package/dist/lib/openapi/collectors/param.collector.js +64 -0
- package/dist/lib/openapi/collectors/schema.collector.d.ts +11 -0
- package/dist/lib/openapi/collectors/schema.collector.js +37 -0
- package/dist/lib/openapi/constants.d.ts +46 -0
- package/dist/lib/openapi/constants.js +61 -0
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.d.ts +2 -0
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-method.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-method.decorator.js +11 -0
- package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-parameter.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-request-body.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-response.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-response.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-security.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-security.decorator.js +10 -0
- package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +3 -0
- package/dist/lib/openapi/decorators/api-tag.decorator.js +13 -0
- package/dist/lib/openapi/decorators/index.d.ts +7 -0
- package/dist/lib/openapi/decorators/index.js +23 -0
- package/dist/lib/openapi/helpers/index.d.ts +7 -0
- package/dist/lib/openapi/helpers/index.js +23 -0
- package/dist/lib/openapi/helpers/method.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/method.helper.js +20 -0
- package/dist/lib/openapi/helpers/openapi.helper.d.ts +7 -0
- package/dist/lib/openapi/helpers/openapi.helper.js +51 -0
- package/dist/lib/openapi/helpers/parameter.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/parameter.helper.js +16 -0
- package/dist/lib/openapi/helpers/request-body.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/request-body.helper.js +9 -0
- package/dist/lib/openapi/helpers/response.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/response.helper.js +18 -0
- package/dist/lib/openapi/helpers/security.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/security.helper.js +17 -0
- package/dist/lib/openapi/helpers/tag.helper.d.ts +3 -0
- package/dist/lib/openapi/helpers/tag.helper.js +10 -0
- package/dist/lib/openapi/index.d.ts +6 -0
- package/dist/lib/openapi/index.js +22 -0
- package/dist/lib/openapi/metadata.registry.d.ts +29 -0
- package/dist/lib/openapi/metadata.registry.js +41 -0
- package/dist/lib/openapi/types.d.ts +131 -0
- package/dist/stores/index.d.ts +1 -0
- package/dist/{common/openapi → stores}/index.js +1 -2
- package/dist/stores/scope.store.d.ts +14 -0
- package/dist/stores/scope.store.js +29 -0
- package/dist/type.d.ts +13 -2
- package/hyper-express-decorators.d.ts +1 -0
- package/package.json +73 -60
- package/scripts/clean.js +56 -0
- package/scripts/test-server.ts +85 -0
- package/tsconfig.json +18 -13
- package/vitest.config.mjs +30 -0
- package/vitest.json +0 -0
- package/.mocharc.js +0 -5
- package/dist/__internals/store.d.ts +0 -10
- package/dist/__internals/store.js +0 -17
- package/dist/__internals/stores/middleware.store.d.ts +0 -7
- package/dist/__internals/stores/middleware.store.js +0 -19
- package/dist/__internals/stores/params.store.d.ts +0 -21
- package/dist/__internals/stores/params.store.js +0 -65
- package/dist/__internals/stores/routes.store.d.ts +0 -17
- package/dist/__internals/stores/routes.store.js +0 -43
- package/dist/__internals/stores/store.interface.d.ts +0 -8
- package/dist/__internals/transform/method.transform.d.ts +0 -2
- package/dist/__internals/transform/method.transform.js +0 -20
- package/dist/__internals/transform/pass.transfrom.d.ts +0 -1
- package/dist/__internals/utils/mixin.utils.d.ts +0 -11
- package/dist/__internals/utils/mixin.utils.js +0 -34
- package/dist/__internals/utils/router.d.ts +0 -1
- package/dist/__internals/utils/router.js +0 -2
- package/dist/common/openapi/collect-class-data.d.ts +0 -21
- package/dist/common/openapi/collect-class-data.js +0 -45
- package/dist/common/openapi/collect-function-data.d.ts +0 -32
- package/dist/common/openapi/collect-function-data.js +0 -70
- package/dist/common/openapi/index.d.ts +0 -2
- /package/dist/__internals/stores/{index.d.ts → metadata.store.d.ts} +0 -0
- /package/dist/__internals/stores/{index.js → metadata.store.js} +0 -0
- /package/dist/{__internals/stores/store.interface.js → lib/openapi/types.js} +0 -0
package/dist/decorators/index.js
CHANGED
|
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./HyperApp"), exports);
|
|
18
18
|
__exportStar(require("./HyperModule"), exports);
|
|
19
19
|
__exportStar(require("./HyperController"), exports);
|
|
20
|
+
__exportStar(require("./HyperService"), exports);
|
|
20
21
|
__exportStar(require("./Middleware"), exports);
|
|
21
22
|
__exportStar(require("./Scope"), exports);
|
|
22
23
|
__exportStar(require("./Role"), exports);
|
|
@@ -25,3 +26,5 @@ __exportStar(require("./types"), exports);
|
|
|
25
26
|
__exportStar(require("./Http"), exports);
|
|
26
27
|
__exportStar(require("./Pass"), exports);
|
|
27
28
|
__exportStar(require("./File"), exports);
|
|
29
|
+
__exportStar(require("./Messaging"), exports);
|
|
30
|
+
__exportStar(require("./Output"), exports);
|
|
@@ -1,13 +1,35 @@
|
|
|
1
|
-
import type { MiddlewareHandler, Request, Response, ServerConstructorOptions } from "hyper-express";
|
|
1
|
+
import type { MiddlewareHandler, MiddlewareNext, Request, Response, ServerConstructorOptions } from "hyper-express";
|
|
2
|
+
import { InjectionToken, RegistrationOptions } from "tsyringe";
|
|
3
|
+
import { IMessageTransport } from "../common/transport";
|
|
4
|
+
export interface OnInit {
|
|
5
|
+
onInit(): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
export interface IsSingleton {
|
|
8
|
+
isSingleton(): boolean;
|
|
9
|
+
}
|
|
2
10
|
export type Constructor<R extends any = any> = new (...args: any[]) => R;
|
|
11
|
+
export type ImportObject = {
|
|
12
|
+
token: InjectionToken;
|
|
13
|
+
useClass?: Constructor;
|
|
14
|
+
useValue?: any;
|
|
15
|
+
useFactory?: (...args: any[]) => any;
|
|
16
|
+
useToken?: InjectionToken;
|
|
17
|
+
options?: RegistrationOptions;
|
|
18
|
+
};
|
|
19
|
+
export type ImportType = Constructor<Partial<OnInit> & Partial<IsSingleton>> | InjectionToken | ImportObject;
|
|
3
20
|
export type ConstructorDecorator = (target: Constructor, kay?: any, descriptor?: PropertyDescriptor) => Constructor;
|
|
4
21
|
export type HyperClassDecorator<T> = (options?: T) => ConstructorDecorator;
|
|
5
22
|
export type HyperMethodDecorator<T> = (options?: T) => (target: any, key?: any, descriptor?: PropertyDescriptor) => void;
|
|
6
23
|
export interface LogSpaces {
|
|
24
|
+
modules: boolean;
|
|
7
25
|
controllers: boolean;
|
|
8
26
|
middleware: boolean;
|
|
9
27
|
routes: boolean;
|
|
10
28
|
}
|
|
29
|
+
export interface IHyperHooks {
|
|
30
|
+
onBeforeInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
31
|
+
onAfterInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
32
|
+
}
|
|
11
33
|
export interface HyperAppMetadata {
|
|
12
34
|
name?: string;
|
|
13
35
|
version?: string;
|
|
@@ -16,31 +38,35 @@ export interface HyperAppMetadata {
|
|
|
16
38
|
license?: string;
|
|
17
39
|
prefix?: string;
|
|
18
40
|
logger?: (...args: any[]) => void;
|
|
19
|
-
logs?: LogSpaces
|
|
41
|
+
logs?: Partial<LogSpaces>;
|
|
20
42
|
modules: Constructor[];
|
|
21
|
-
imports?:
|
|
43
|
+
imports?: ImportType[];
|
|
22
44
|
options?: ServerConstructorOptions;
|
|
45
|
+
transports?: IMessageTransport[];
|
|
46
|
+
hooks?: IHyperHooks | Constructor<IHyperHooks>;
|
|
47
|
+
}
|
|
48
|
+
export interface HyperAppDecorator {
|
|
49
|
+
(options?: HyperAppMetadata): (target: Constructor) => Constructor;
|
|
23
50
|
}
|
|
24
|
-
export type HyperAppDecorator = (options?: HyperAppMetadata) => (target: Constructor) => Constructor;
|
|
25
51
|
export type HyperModuleMetadata = {
|
|
26
|
-
path
|
|
52
|
+
path?: string;
|
|
27
53
|
name?: string;
|
|
28
54
|
roles?: string[];
|
|
29
55
|
scopes?: string[];
|
|
30
56
|
modules?: Constructor[];
|
|
31
57
|
controllers?: Constructor[];
|
|
32
|
-
imports?:
|
|
58
|
+
imports?: ImportType[];
|
|
33
59
|
};
|
|
34
60
|
export type HyperModuleDecorator = HyperClassDecorator<HyperModuleMetadata>;
|
|
35
61
|
export type HyperControllerMetadata = {
|
|
36
62
|
path?: string;
|
|
37
63
|
roles?: string[];
|
|
38
64
|
scopes?: string[];
|
|
39
|
-
imports?:
|
|
65
|
+
imports?: ImportType[];
|
|
40
66
|
};
|
|
41
67
|
export type HyperControllerDecorator = HyperClassDecorator<HyperControllerMetadata | string>;
|
|
42
68
|
export type ParameterResolver = (req: Request, res: Response) => any | Promise<any>;
|
|
43
|
-
export type
|
|
69
|
+
export type HyperParameterMetadata = {
|
|
44
70
|
params: Record<string, {
|
|
45
71
|
index: number;
|
|
46
72
|
type: any;
|
|
@@ -48,6 +74,8 @@ export type HyperParamerMetadata = {
|
|
|
48
74
|
name: string;
|
|
49
75
|
method: string;
|
|
50
76
|
resolver: ParameterResolver;
|
|
77
|
+
schema?: any;
|
|
78
|
+
isWholeSource?: boolean;
|
|
51
79
|
}[]>;
|
|
52
80
|
};
|
|
53
81
|
export type HyperParamDecorator = (key: string) => (target: any, key: string, index: number) => void;
|
|
@@ -61,7 +89,7 @@ export type RoleMap<T> = {
|
|
|
61
89
|
* It can accept a single role, an array of roles, or a function that evaluates roles dynamically.
|
|
62
90
|
*/
|
|
63
91
|
export type RoleType<T extends string = string> = T | T[] | RoleMap<T> | RoleMap<T>[];
|
|
64
|
-
export type ScopeMap<T> = {
|
|
92
|
+
export type ScopeMap<T extends string = string> = {
|
|
65
93
|
scope: T;
|
|
66
94
|
description: string;
|
|
67
95
|
message?: string;
|
|
@@ -80,10 +108,17 @@ export interface RouteMetadata {
|
|
|
80
108
|
method: string;
|
|
81
109
|
path: string;
|
|
82
110
|
propertyKey: string;
|
|
111
|
+
options?: any;
|
|
83
112
|
handler: (...args: any[]) => any;
|
|
84
113
|
}
|
|
114
|
+
export declare abstract class MiddlewareClass {
|
|
115
|
+
abstract handle(req: Request, res: Response, next: MiddlewareNext): void;
|
|
116
|
+
}
|
|
117
|
+
export interface MiddlewareClassConstructor {
|
|
118
|
+
new (...args: any[]): MiddlewareClass;
|
|
119
|
+
}
|
|
85
120
|
/**
|
|
86
121
|
* Type definition for Middleware.
|
|
87
122
|
* Middleware can be a single handler or an array of handlers.
|
|
88
123
|
*/
|
|
89
|
-
export type MiddlewareType = MiddlewareHandler |
|
|
124
|
+
export type MiddlewareType = MiddlewareHandler | MiddlewareClassConstructor;
|
package/dist/decorators/types.js
CHANGED
package/dist/extension.js
CHANGED
|
@@ -18,6 +18,9 @@ const requestMethods = {
|
|
|
18
18
|
setScopes(scopes) {
|
|
19
19
|
(0, helpers_1.setScopes)(this, scopes);
|
|
20
20
|
},
|
|
21
|
+
setFullScopes() {
|
|
22
|
+
(0, helpers_1.setScopes)(this, ["*"]);
|
|
23
|
+
},
|
|
21
24
|
hasScopes(scopes) {
|
|
22
25
|
return (0, helpers_1.hasScopes)(this, scopes);
|
|
23
26
|
},
|
|
@@ -25,8 +28,14 @@ const requestMethods = {
|
|
|
25
28
|
return (0, helpers_1.getScopes)(this);
|
|
26
29
|
},
|
|
27
30
|
setRoleScopes(role, scopes) {
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
(0, helpers_1.setRole)(this, role);
|
|
32
|
+
(0, helpers_1.setScopes)(this, scopes);
|
|
33
|
+
},
|
|
34
|
+
setValue(key, value) {
|
|
35
|
+
(0, helpers_1.setValue)(this, key, value);
|
|
36
|
+
},
|
|
37
|
+
getValue(key, defaultValue) {
|
|
38
|
+
return (0, helpers_1.getValue)(this, key, defaultValue);
|
|
30
39
|
},
|
|
31
40
|
};
|
|
32
41
|
/////////////////////////////
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,13 @@ export * from "./constants";
|
|
|
3
3
|
export * from "./extension";
|
|
4
4
|
export * from "./decorators";
|
|
5
5
|
export * from "./common/helpers";
|
|
6
|
+
export * from "./__internals/helpers/tree.helper";
|
|
6
7
|
export * from "./common/bootstrap";
|
|
7
8
|
export * from "hyper-express";
|
|
8
9
|
export * from "tsyringe";
|
|
10
|
+
export * from "./stores";
|
|
9
11
|
export * from "./type";
|
|
12
|
+
export * from "./common/transport";
|
|
13
|
+
export * from "./common/message-bus";
|
|
14
|
+
export * from "./__internals/transform/transform.registry";
|
|
15
|
+
export * from "./lib/openapi";
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,13 @@ __exportStar(require("./constants"), exports);
|
|
|
19
19
|
__exportStar(require("./extension"), exports);
|
|
20
20
|
__exportStar(require("./decorators"), exports);
|
|
21
21
|
__exportStar(require("./common/helpers"), exports);
|
|
22
|
+
__exportStar(require("./__internals/helpers/tree.helper"), exports);
|
|
22
23
|
__exportStar(require("./common/bootstrap"), exports);
|
|
23
24
|
__exportStar(require("hyper-express"), exports);
|
|
24
25
|
__exportStar(require("tsyringe"), exports);
|
|
26
|
+
__exportStar(require("./stores"), exports);
|
|
25
27
|
__exportStar(require("./type"), exports);
|
|
28
|
+
__exportStar(require("./common/transport"), exports);
|
|
29
|
+
__exportStar(require("./common/message-bus"), exports);
|
|
30
|
+
__exportStar(require("./__internals/transform/transform.registry"), exports);
|
|
31
|
+
__exportStar(require("./lib/openapi"), exports);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectClassMetadata = collectClassMetadata;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
const method_collector_1 = require("./method.collector");
|
|
7
|
+
const function_util_1 = require("../../../__internals/utils/function.util");
|
|
8
|
+
const metadata_registry_1 = require("../metadata.registry");
|
|
9
|
+
function collectClassMetadata(target) {
|
|
10
|
+
var _a;
|
|
11
|
+
const prototype = Reflect.getPrototypeOf(target);
|
|
12
|
+
const constructor = prototype === null || prototype === void 0 ? void 0 : prototype.constructor;
|
|
13
|
+
const name = target.name || (constructor === null || constructor === void 0 ? void 0 : constructor.name) || ((_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name);
|
|
14
|
+
// Extraemos las metadata de la clase
|
|
15
|
+
let tags = Reflect.getMetadata(constants_1.TAGS, target) || [];
|
|
16
|
+
let security = Reflect.getMetadata(constants_1.SECURITY, target) || [];
|
|
17
|
+
// Invoke custom class collectors
|
|
18
|
+
metadata_registry_1.openApiRegistry.getCollectors("class").forEach(collector => {
|
|
19
|
+
const data = collector(target);
|
|
20
|
+
if (data === null || data === void 0 ? void 0 : data.tags)
|
|
21
|
+
tags = [...tags, ...data.tags];
|
|
22
|
+
if (data === null || data === void 0 ? void 0 : data.security)
|
|
23
|
+
security = [...security, ...data.security];
|
|
24
|
+
});
|
|
25
|
+
// Si no tenemos tags, intentamos inferirlos
|
|
26
|
+
if (tags.length === 0) {
|
|
27
|
+
tags.push({ name });
|
|
28
|
+
}
|
|
29
|
+
// Si no tenemos seguridad, intentamos asignar un valor predeterminado
|
|
30
|
+
if (security.length === 0) {
|
|
31
|
+
security.push({ bearerAuth: [] });
|
|
32
|
+
}
|
|
33
|
+
// Obtenemos todos los métodos de la clase
|
|
34
|
+
const methodNames = Object.getOwnPropertyNames(target.prototype || {}).filter((method) => method !== "constructor");
|
|
35
|
+
// Creamos una lista con la metadata de cada uno de los métodos
|
|
36
|
+
const methods = {};
|
|
37
|
+
methodNames.forEach((methodName) => {
|
|
38
|
+
let methodMetadata = (0, method_collector_1.collectMethodMetadata)(target.prototype, methodName);
|
|
39
|
+
// Invoke custom method collectors
|
|
40
|
+
metadata_registry_1.openApiRegistry.getCollectors("method").forEach(collector => {
|
|
41
|
+
const data = collector(target.prototype, methodName);
|
|
42
|
+
methodMetadata = Object.assign(Object.assign({}, methodMetadata), data);
|
|
43
|
+
});
|
|
44
|
+
// Si el método no tiene parámetros definidos, intentamos inferirlos
|
|
45
|
+
if (!methodMetadata.parameters || methodMetadata.parameters.length === 0) {
|
|
46
|
+
const methodParams = (0, function_util_1.extractArgsNames)(target.prototype[methodName]);
|
|
47
|
+
methodParams === null || methodParams === void 0 ? void 0 : methodParams.forEach((paramName, index) => {
|
|
48
|
+
const inferredParam = {
|
|
49
|
+
name: paramName || `param${index}`,
|
|
50
|
+
in: "query",
|
|
51
|
+
required: true,
|
|
52
|
+
schema: {
|
|
53
|
+
type: "string",
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
methodMetadata.parameters || (methodMetadata.parameters = []);
|
|
57
|
+
methodMetadata.parameters.push(inferredParam);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
methods[methodName] = methodMetadata;
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
tags,
|
|
64
|
+
security,
|
|
65
|
+
methods,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./class.collector"), exports);
|
|
18
|
+
__exportStar(require("./method.collector"), exports);
|
|
19
|
+
__exportStar(require("./param.collector"), exports);
|
|
20
|
+
__exportStar(require("./schema.collector"), exports);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectMethodMetadata = collectMethodMetadata;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const param_collector_1 = require("./param.collector");
|
|
6
|
+
const constants_2 = require("../../../__internals/constants");
|
|
7
|
+
const transform_registry_1 = require("../../../__internals/transform/transform.registry");
|
|
8
|
+
function collectMethodMetadata(target, methodName) {
|
|
9
|
+
const methodMetadata = {};
|
|
10
|
+
// Extraemos la metadata del método
|
|
11
|
+
const summary = Reflect.getMetadata(constants_1.METHOD_SUMMARY, target, methodName);
|
|
12
|
+
const operationId = Reflect.getMetadata(constants_1.METHOD_OPERATION_ID, target, methodName);
|
|
13
|
+
const tags = Reflect.getMetadata(constants_1.METHOD_TAGS, target, methodName);
|
|
14
|
+
const security = Reflect.getMetadata(constants_1.SECURITY, target, methodName);
|
|
15
|
+
// Extraemos las respuestas del método
|
|
16
|
+
const responses = Reflect.getMetadata(constants_1.RESPONSES, target, methodName) || {};
|
|
17
|
+
// Extraemos los parámetros del método
|
|
18
|
+
const parameters = (0, param_collector_1.collectParameterMetadata)(target, methodName);
|
|
19
|
+
// Extraemos la información del cuerpo de la solicitud
|
|
20
|
+
const requestBody = {
|
|
21
|
+
description: Reflect.getMetadata(constants_1.REQUEST_BODY_DESCRIPTION, target, methodName),
|
|
22
|
+
content: Reflect.getMetadata(constants_1.REQUEST_BODY_CONTENT, target, methodName),
|
|
23
|
+
};
|
|
24
|
+
// Bridge @Body to OpenAPI
|
|
25
|
+
const hyperParams = Reflect.getMetadata(constants_2.KEY_PARAMS_PARAM, target[methodName]);
|
|
26
|
+
if (hyperParams && hyperParams.params[methodName]) {
|
|
27
|
+
const bodyParam = hyperParams.params[methodName].find(p => ['body', 'BODY', 'req'].includes(p.key));
|
|
28
|
+
if (bodyParam) {
|
|
29
|
+
const targetSchema = bodyParam.schema;
|
|
30
|
+
if (targetSchema) {
|
|
31
|
+
const bodySchema = transform_registry_1.transformRegistry.getOpenApiSchema(targetSchema);
|
|
32
|
+
if (bodySchema) {
|
|
33
|
+
requestBody.content = requestBody.content || {};
|
|
34
|
+
requestBody.content['application/json'] = {
|
|
35
|
+
schema: bodySchema
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// Bridging @Output / return type to OpenAPI
|
|
42
|
+
const outputSchema = Reflect.getMetadata(constants_2.KEY_OUTPUT_SCHEMA, target, methodName)
|
|
43
|
+
|| Reflect.getMetadata(constants_2.DESIGN_RETURNTYPE, target, methodName);
|
|
44
|
+
if (outputSchema && outputSchema !== Object && outputSchema !== Promise) {
|
|
45
|
+
const schema = transform_registry_1.transformRegistry.getOpenApiSchema(outputSchema);
|
|
46
|
+
if (schema) {
|
|
47
|
+
responses['200'] = responses['200'] || { description: 'Success' };
|
|
48
|
+
responses['200'].content = responses['200'].content || {};
|
|
49
|
+
responses['200'].content['application/json'] = { schema };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// Asignamos las propiedades al objeto de metadata solo si existen
|
|
53
|
+
if (summary)
|
|
54
|
+
methodMetadata.summary = summary;
|
|
55
|
+
if (operationId)
|
|
56
|
+
methodMetadata.operationId = operationId;
|
|
57
|
+
if (tags)
|
|
58
|
+
methodMetadata.tags = tags;
|
|
59
|
+
if (security)
|
|
60
|
+
methodMetadata.security = security;
|
|
61
|
+
if (responses && Object.keys(responses).length > 0)
|
|
62
|
+
methodMetadata.responses = responses;
|
|
63
|
+
if (parameters.length > 0)
|
|
64
|
+
methodMetadata.parameters = parameters;
|
|
65
|
+
if (requestBody.content)
|
|
66
|
+
methodMetadata.requestBody = requestBody;
|
|
67
|
+
return methodMetadata;
|
|
68
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectParameterMetadata = collectParameterMetadata;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const constants_2 = require("../../../__internals/constants");
|
|
6
|
+
const transform_registry_1 = require("../../../__internals/transform/transform.registry");
|
|
7
|
+
const function_util_1 = require("../../../__internals/utils/function.util");
|
|
8
|
+
function collectParameterMetadata(target, methodName) {
|
|
9
|
+
const parameters = Reflect.getMetadata(constants_1.PARAMETERS, target, methodName) || [];
|
|
10
|
+
const hyperParams = Reflect.getMetadata(constants_2.KEY_PARAMS_PARAM, target[methodName]);
|
|
11
|
+
if (hyperParams && hyperParams.params[methodName]) {
|
|
12
|
+
hyperParams.params[methodName].forEach((p) => {
|
|
13
|
+
// Ignore body, req, res as they are not standard "parameters" in OpenAPI terms (body is separate)
|
|
14
|
+
if (['req', 'res', 'body', 'BODY'].includes(p.key))
|
|
15
|
+
return;
|
|
16
|
+
const locationMap = {
|
|
17
|
+
'query': 'query',
|
|
18
|
+
'params': 'path',
|
|
19
|
+
'headers': 'header',
|
|
20
|
+
'cookie': 'cookie'
|
|
21
|
+
};
|
|
22
|
+
const location = locationMap[p.key] || 'query';
|
|
23
|
+
if (p.isWholeSource && p.schema) {
|
|
24
|
+
const schema = transform_registry_1.transformRegistry.getOpenApiSchema(p.schema);
|
|
25
|
+
if (schema && schema.properties) {
|
|
26
|
+
Object.keys(schema.properties).forEach((propKey) => {
|
|
27
|
+
parameters.push({
|
|
28
|
+
name: propKey,
|
|
29
|
+
in: location,
|
|
30
|
+
required: (schema.required || []).includes(propKey),
|
|
31
|
+
schema: schema.properties[propKey]
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
parameters.push({
|
|
38
|
+
name: p.name,
|
|
39
|
+
in: location,
|
|
40
|
+
required: true, // TODO: detect optionality from design:paramtypes or metadata
|
|
41
|
+
schema: p.schema ? transform_registry_1.transformRegistry.getOpenApiSchema(p.schema) : { type: 'string' }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// Fallback to design:paramtypes if no hyper-decor metadata found
|
|
47
|
+
if (parameters.length === 0) {
|
|
48
|
+
const methodParams = Reflect.getMetadata("design:paramtypes", target, methodName) || [];
|
|
49
|
+
const paramNames = (0, function_util_1.extractArgsNames)(target[methodName]);
|
|
50
|
+
methodParams.forEach((paramType, index) => {
|
|
51
|
+
var _a;
|
|
52
|
+
const name = paramNames && paramNames[index] ? paramNames[index] : `param${index}`;
|
|
53
|
+
parameters.push({
|
|
54
|
+
name,
|
|
55
|
+
in: "query",
|
|
56
|
+
required: true,
|
|
57
|
+
schema: {
|
|
58
|
+
type: ((_a = paramType === null || paramType === void 0 ? void 0 : paramType.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'number' ? 'number' : 'string',
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return parameters;
|
|
64
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Schema } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Collector responsible for transforming DTO classes into OpenAPI Schema objects.
|
|
5
|
+
* Uses design:type and property inspection.
|
|
6
|
+
*/
|
|
7
|
+
export declare function collectSchema(Target: any): Schema;
|
|
8
|
+
/**
|
|
9
|
+
* Infer OpenAPI type from JavaScript constructor names.
|
|
10
|
+
*/
|
|
11
|
+
export declare function inferType(constructorName: string): string;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectSchema = collectSchema;
|
|
4
|
+
exports.inferType = inferType;
|
|
5
|
+
require("reflect-metadata");
|
|
6
|
+
/**
|
|
7
|
+
* Collector responsible for transforming DTO classes into OpenAPI Schema objects.
|
|
8
|
+
* Uses design:type and property inspection.
|
|
9
|
+
*/
|
|
10
|
+
function collectSchema(Target) {
|
|
11
|
+
if (!Target || typeof Target !== "function") {
|
|
12
|
+
return { type: "object" };
|
|
13
|
+
}
|
|
14
|
+
const schema = {
|
|
15
|
+
type: "object",
|
|
16
|
+
properties: {},
|
|
17
|
+
};
|
|
18
|
+
// Note: Standard reflect-metadata has limitations for property enumeration.
|
|
19
|
+
// In a full implementation, we might use a custom decorator or
|
|
20
|
+
// class-transformer/class-validator if available.
|
|
21
|
+
// For now, we provide the structure to be extended.
|
|
22
|
+
return schema;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Infer OpenAPI type from JavaScript constructor names.
|
|
26
|
+
*/
|
|
27
|
+
function inferType(constructorName) {
|
|
28
|
+
const map = {
|
|
29
|
+
String: "string",
|
|
30
|
+
Number: "number",
|
|
31
|
+
Boolean: "boolean",
|
|
32
|
+
Array: "array",
|
|
33
|
+
Object: "object",
|
|
34
|
+
Date: "string", // Dates are strings in OpenAPI
|
|
35
|
+
};
|
|
36
|
+
return map[constructorName] || "string";
|
|
37
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const OPENAPI_VERSION = "3.0.0";
|
|
2
|
+
export declare const INFO_TITLE = "openapi:info:title";
|
|
3
|
+
export declare const INFO_DESCRIPTION = "openapi:info:description";
|
|
4
|
+
export declare const INFO_VERSION = "openapi:info:version";
|
|
5
|
+
export declare const INFO_TERMS_OF_SERVICE = "openapi:info:termsOfService";
|
|
6
|
+
export declare const INFO_CONTACT = "openapi:info:contact";
|
|
7
|
+
export declare const INFO_LICENSE = "openapi:info:license";
|
|
8
|
+
export declare const PATHS = "openapi:paths";
|
|
9
|
+
export declare const METHOD_GET = "openapi:method:get";
|
|
10
|
+
export declare const METHOD_POST = "openapi:method:post";
|
|
11
|
+
export declare const METHOD_PUT = "openapi:method:put";
|
|
12
|
+
export declare const METHOD_DELETE = "openapi:method:delete";
|
|
13
|
+
export declare const METHOD_PATCH = "openapi:method:patch";
|
|
14
|
+
export declare const METHOD_HEAD = "openapi:method:head";
|
|
15
|
+
export declare const METHOD_OPTIONS = "openapi:method:options";
|
|
16
|
+
export declare const METHOD_TRACE = "openapi:method:trace";
|
|
17
|
+
export declare const PARAMETERS = "openapi:parameters";
|
|
18
|
+
export declare const PARAM_NAME = "openapi:parameter:name";
|
|
19
|
+
export declare const PARAM_IN = "openapi:parameter:in";
|
|
20
|
+
export declare const PARAM_REQUIRED = "openapi:parameter:required";
|
|
21
|
+
export declare const PARAM_DESCRIPTION = "openapi:parameter:description";
|
|
22
|
+
export declare const PARAM_SCHEMA = "openapi:parameter:schema";
|
|
23
|
+
export declare const REQUEST_BODY = "openapi:requestBody";
|
|
24
|
+
export declare const REQUEST_BODY_DESCRIPTION = "openapi:requestBody:description";
|
|
25
|
+
export declare const REQUEST_BODY_CONTENT = "openapi:requestBody:content";
|
|
26
|
+
export declare const RESPONSES = "openapi:responses";
|
|
27
|
+
export declare const RESPONSE_DESCRIPTION = "openapi:response:description";
|
|
28
|
+
export declare const RESPONSE_CONTENT = "openapi:response:content";
|
|
29
|
+
export declare const RESPONSE_SCHEMA = "openapi:response:schema";
|
|
30
|
+
export declare const SECURITY = "openapi:security";
|
|
31
|
+
export declare const SECURITY_SCHEME = "openapi:security:scheme";
|
|
32
|
+
export declare const TAGS = "openapi:tags";
|
|
33
|
+
export declare const TAG_NAME = "openapi:tag:name";
|
|
34
|
+
export declare const TAG_DESCRIPTION = "openapi:tag:description";
|
|
35
|
+
export declare const METHOD_METADATA = "openapi:method:metadata";
|
|
36
|
+
export declare const METHOD_SUMMARY = "openapi:method:summary";
|
|
37
|
+
export declare const METHOD_OPERATION_ID = "openapi:method:operationId";
|
|
38
|
+
export declare const METHOD_TAGS = "openapi:method:tags";
|
|
39
|
+
export declare const COMPONENTS = "openapi:components";
|
|
40
|
+
export declare const COMPONENTS_SCHEMAS = "openapi:components:schemas";
|
|
41
|
+
export declare const COMPONENTS_RESPONSES = "openapi:components:responses";
|
|
42
|
+
export declare const COMPONENTS_PARAMETERS = "openapi:components:parameters";
|
|
43
|
+
export declare const COMPONENTS_SECURITY_SCHEMES = "openapi:components:securitySchemes";
|
|
44
|
+
export declare const SECURITY_API_KEY = "openapi:security:apiKey";
|
|
45
|
+
export declare const SECURITY_OAUTH2 = "openapi:security:oauth2";
|
|
46
|
+
export declare const SECURITY_OIDC = "openapi:security:oidc";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// constants.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.SECURITY_OIDC = exports.SECURITY_OAUTH2 = exports.SECURITY_API_KEY = exports.COMPONENTS_SECURITY_SCHEMES = exports.COMPONENTS_PARAMETERS = exports.COMPONENTS_RESPONSES = exports.COMPONENTS_SCHEMAS = exports.COMPONENTS = exports.METHOD_TAGS = exports.METHOD_OPERATION_ID = exports.METHOD_SUMMARY = exports.METHOD_METADATA = exports.TAG_DESCRIPTION = exports.TAG_NAME = exports.TAGS = exports.SECURITY_SCHEME = exports.SECURITY = exports.RESPONSE_SCHEMA = exports.RESPONSE_CONTENT = exports.RESPONSE_DESCRIPTION = exports.RESPONSES = exports.REQUEST_BODY_CONTENT = exports.REQUEST_BODY_DESCRIPTION = exports.REQUEST_BODY = exports.PARAM_SCHEMA = exports.PARAM_DESCRIPTION = exports.PARAM_REQUIRED = exports.PARAM_IN = exports.PARAM_NAME = exports.PARAMETERS = exports.METHOD_TRACE = exports.METHOD_OPTIONS = exports.METHOD_HEAD = exports.METHOD_PATCH = exports.METHOD_DELETE = exports.METHOD_PUT = exports.METHOD_POST = exports.METHOD_GET = exports.PATHS = exports.INFO_LICENSE = exports.INFO_CONTACT = exports.INFO_TERMS_OF_SERVICE = exports.INFO_VERSION = exports.INFO_DESCRIPTION = exports.INFO_TITLE = exports.OPENAPI_VERSION = void 0;
|
|
5
|
+
// OpenAPI Version
|
|
6
|
+
exports.OPENAPI_VERSION = "3.0.0";
|
|
7
|
+
// Info Metadata (Información general sobre la API)
|
|
8
|
+
exports.INFO_TITLE = "openapi:info:title";
|
|
9
|
+
exports.INFO_DESCRIPTION = "openapi:info:description";
|
|
10
|
+
exports.INFO_VERSION = "openapi:info:version";
|
|
11
|
+
exports.INFO_TERMS_OF_SERVICE = "openapi:info:termsOfService";
|
|
12
|
+
exports.INFO_CONTACT = "openapi:info:contact";
|
|
13
|
+
exports.INFO_LICENSE = "openapi:info:license";
|
|
14
|
+
// Paths (Rutas de la API)
|
|
15
|
+
exports.PATHS = "openapi:paths";
|
|
16
|
+
exports.METHOD_GET = "openapi:method:get";
|
|
17
|
+
exports.METHOD_POST = "openapi:method:post";
|
|
18
|
+
exports.METHOD_PUT = "openapi:method:put";
|
|
19
|
+
exports.METHOD_DELETE = "openapi:method:delete";
|
|
20
|
+
exports.METHOD_PATCH = "openapi:method:patch";
|
|
21
|
+
exports.METHOD_HEAD = "openapi:method:head";
|
|
22
|
+
exports.METHOD_OPTIONS = "openapi:method:options";
|
|
23
|
+
exports.METHOD_TRACE = "openapi:method:trace";
|
|
24
|
+
// Parameters (Parámetros de los métodos)
|
|
25
|
+
exports.PARAMETERS = "openapi:parameters";
|
|
26
|
+
exports.PARAM_NAME = "openapi:parameter:name";
|
|
27
|
+
exports.PARAM_IN = "openapi:parameter:in"; // query, header, path, cookie
|
|
28
|
+
exports.PARAM_REQUIRED = "openapi:parameter:required";
|
|
29
|
+
exports.PARAM_DESCRIPTION = "openapi:parameter:description";
|
|
30
|
+
exports.PARAM_SCHEMA = "openapi:parameter:schema";
|
|
31
|
+
// RequestBody (Cuerpo de la solicitud)
|
|
32
|
+
exports.REQUEST_BODY = "openapi:requestBody";
|
|
33
|
+
exports.REQUEST_BODY_DESCRIPTION = "openapi:requestBody:description";
|
|
34
|
+
exports.REQUEST_BODY_CONTENT = "openapi:requestBody:content";
|
|
35
|
+
// Responses (Respuestas de los métodos)
|
|
36
|
+
exports.RESPONSES = "openapi:responses";
|
|
37
|
+
exports.RESPONSE_DESCRIPTION = "openapi:response:description";
|
|
38
|
+
exports.RESPONSE_CONTENT = "openapi:response:content";
|
|
39
|
+
exports.RESPONSE_SCHEMA = "openapi:response:schema";
|
|
40
|
+
// Security (Esquemas de seguridad)
|
|
41
|
+
exports.SECURITY = "openapi:security";
|
|
42
|
+
exports.SECURITY_SCHEME = "openapi:security:scheme"; // Esquemas de seguridad como apiKey, oauth2, etc.
|
|
43
|
+
// Tags (Etiquetas de los métodos)
|
|
44
|
+
exports.TAGS = "openapi:tags";
|
|
45
|
+
exports.TAG_NAME = "openapi:tag:name";
|
|
46
|
+
exports.TAG_DESCRIPTION = "openapi:tag:description";
|
|
47
|
+
// Method Metadata (Metadatos adicionales de los métodos)
|
|
48
|
+
exports.METHOD_METADATA = "openapi:method:metadata";
|
|
49
|
+
exports.METHOD_SUMMARY = "openapi:method:summary";
|
|
50
|
+
exports.METHOD_OPERATION_ID = "openapi:method:operationId";
|
|
51
|
+
exports.METHOD_TAGS = "openapi:method:tags";
|
|
52
|
+
// Components (Componentes reutilizables)
|
|
53
|
+
exports.COMPONENTS = "openapi:components";
|
|
54
|
+
exports.COMPONENTS_SCHEMAS = "openapi:components:schemas"; // Esquemas reutilizables de parámetros y respuestas
|
|
55
|
+
exports.COMPONENTS_RESPONSES = "openapi:components:responses"; // Respuestas reutilizables
|
|
56
|
+
exports.COMPONENTS_PARAMETERS = "openapi:components:parameters"; // Parámetros reutilizables
|
|
57
|
+
exports.COMPONENTS_SECURITY_SCHEMES = "openapi:components:securitySchemes"; // Esquemas de seguridad reutilizables
|
|
58
|
+
// Security Schemes (Esquemas de seguridad)
|
|
59
|
+
exports.SECURITY_API_KEY = "openapi:security:apiKey";
|
|
60
|
+
exports.SECURITY_OAUTH2 = "openapi:security:oauth2";
|
|
61
|
+
exports.SECURITY_OIDC = "openapi:security:oidc"; // OpenID Connect
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBearerAuth = ApiBearerAuth;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const security_helper_1 = require("../helpers/security.helper");
|
|
6
|
+
function ApiBearerAuth(name = 'bearerAuth') {
|
|
7
|
+
return (target, propertyKey, descriptor) => {
|
|
8
|
+
(0, security_helper_1.apiSecurity)(target, { [name]: [] }, propertyKey);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiMethod = ApiMethod;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const method_helper_1 = require("../helpers/method.helper");
|
|
6
|
+
function ApiMethod(options) {
|
|
7
|
+
return (target, propertyKey, descriptor) => {
|
|
8
|
+
(0, method_helper_1.apimethod)(target, propertyKey, options);
|
|
9
|
+
return descriptor;
|
|
10
|
+
};
|
|
11
|
+
}
|