1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.ApiSecurity = void 0;
|
4 | const lodash_1 = require("lodash");
|
5 | const constants_1 = require("../constants");
|
6 | const extend_metadata_util_1 = require("../utils/extend-metadata.util");
|
7 | function ApiSecurity(name, requirements = []) {
|
8 | let metadata;
|
9 | if (lodash_1.isString(name)) {
|
10 | metadata = [{ [name]: requirements }];
|
11 | }
|
12 | else {
|
13 | metadata = [name];
|
14 | }
|
15 | return (target, key, descriptor) => {
|
16 | if (descriptor) {
|
17 | metadata = extend_metadata_util_1.extendMetadata(metadata, constants_1.DECORATORS.API_SECURITY, descriptor.value);
|
18 | Reflect.defineMetadata(constants_1.DECORATORS.API_SECURITY, metadata, descriptor.value);
|
19 | return descriptor;
|
20 | }
|
21 | metadata = extend_metadata_util_1.extendMetadata(metadata, constants_1.DECORATORS.API_SECURITY, target);
|
22 | Reflect.defineMetadata(constants_1.DECORATORS.API_SECURITY, metadata, target);
|
23 | return target;
|
24 | };
|
25 | }
|
26 | exports.ApiSecurity = ApiSecurity;
|