1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 |
|
4 | const constants_1 = require("../../constants");
|
5 | const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
6 | const shared_utils_1 = require("../../utils/shared.utils");
|
7 | const validate_each_util_1 = require("../../utils/validate-each.util");
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 | exports.UseFilters = (...filters) => addExceptionFiltersMetadata(...filters);
|
30 | function addExceptionFiltersMetadata(...filters) {
|
31 | return (target, key, descriptor) => {
|
32 | const isFilterValid = (filter) => filter &&
|
33 | (shared_utils_1.isFunction(filter) || shared_utils_1.isFunction(filter.catch));
|
34 | if (descriptor) {
|
35 | validate_each_util_1.validateEach(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
|
36 | extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
|
37 | return descriptor;
|
38 | }
|
39 | validate_each_util_1.validateEach(target, filters, isFilterValid, '@UseFilters', 'filter');
|
40 | extend_metadata_util_1.extendArrayMetadata(constants_1.EXCEPTION_FILTERS_METADATA, filters, target);
|
41 | return target;
|
42 | };
|
43 | }
|