1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.UseInterceptors = void 0;
|
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 | function UseInterceptors(...interceptors) {
|
30 | return (target, key, descriptor) => {
|
31 | const isInterceptorValid = (interceptor) => interceptor &&
|
32 | ((0, shared_utils_1.isFunction)(interceptor) ||
|
33 | (0, shared_utils_1.isFunction)(interceptor.intercept));
|
34 | if (descriptor) {
|
35 | (0, validate_each_util_1.validateEach)(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
36 | (0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
37 | return descriptor;
|
38 | }
|
39 | (0, validate_each_util_1.validateEach)(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
40 | (0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, target);
|
41 | return target;
|
42 | };
|
43 | }
|
44 | exports.UseInterceptors = UseInterceptors;
|