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