@nestjs/common 11.1.16 → 12.0.0-alpha.1
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/constants.js +35 -38
- package/decorators/core/apply-decorators.js +1 -4
- package/decorators/core/bind.decorator.js +1 -4
- package/decorators/core/catch.decorator.d.ts +1 -1
- package/decorators/core/catch.decorator.js +4 -7
- package/decorators/core/controller.decorator.d.ts +1 -1
- package/decorators/core/controller.decorator.js +10 -13
- package/decorators/core/dependencies.decorator.js +4 -9
- package/decorators/core/exception-filters.decorator.d.ts +1 -1
- package/decorators/core/exception-filters.decorator.js +10 -14
- package/decorators/core/index.d.ts +14 -14
- package/decorators/core/index.js +14 -17
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/inject.decorator.js +9 -12
- package/decorators/core/injectable.decorator.d.ts +2 -2
- package/decorators/core/injectable.decorator.js +7 -11
- package/decorators/core/optional.decorator.js +8 -11
- package/decorators/core/set-metadata.decorator.js +1 -5
- package/decorators/core/use-guards.decorator.d.ts +1 -1
- package/decorators/core/use-guards.decorator.js +10 -13
- package/decorators/core/use-interceptors.decorator.d.ts +1 -1
- package/decorators/core/use-interceptors.decorator.js +10 -13
- package/decorators/core/use-pipes.decorator.d.ts +1 -1
- package/decorators/core/use-pipes.decorator.js +9 -12
- package/decorators/core/version.decorator.d.ts +1 -1
- package/decorators/core/version.decorator.js +3 -6
- package/decorators/http/create-route-param-metadata.decorator.d.ts +6 -5
- package/decorators/http/create-route-param-metadata.decorator.js +48 -16
- package/decorators/http/header.decorator.js +4 -7
- package/decorators/http/http-code.decorator.js +3 -6
- package/decorators/http/index.d.ts +8 -8
- package/decorators/http/index.js +8 -11
- package/decorators/http/redirect.decorator.js +3 -6
- package/decorators/http/render.decorator.js +3 -6
- package/decorators/http/request-mapping.decorator.d.ts +1 -1
- package/decorators/http/request-mapping.decorator.js +28 -32
- package/decorators/http/route-params.decorator.d.ts +153 -3
- package/decorators/http/route-params.decorator.js +124 -49
- package/decorators/http/sse.decorator.d.ts +2 -2
- package/decorators/http/sse.decorator.js +7 -10
- package/decorators/index.d.ts +3 -3
- package/decorators/index.js +3 -6
- package/decorators/modules/global.decorator.js +3 -6
- package/decorators/modules/index.d.ts +2 -2
- package/decorators/modules/index.js +2 -5
- package/decorators/modules/module.decorator.d.ts +1 -1
- package/decorators/modules/module.decorator.js +3 -6
- package/enums/http-status.enum.js +2 -5
- package/enums/index.d.ts +4 -4
- package/enums/index.js +4 -7
- package/enums/request-method.enum.js +2 -5
- package/enums/route-paramtypes.enum.js +2 -5
- package/enums/shutdown-signal.enum.js +2 -5
- package/enums/version-type.enum.js +2 -5
- package/exceptions/bad-gateway.exception.d.ts +1 -1
- package/exceptions/bad-gateway.exception.js +5 -9
- package/exceptions/bad-request.exception.d.ts +1 -1
- package/exceptions/bad-request.exception.js +5 -9
- package/exceptions/conflict.exception.d.ts +1 -1
- package/exceptions/conflict.exception.js +5 -9
- package/exceptions/forbidden.exception.d.ts +1 -1
- package/exceptions/forbidden.exception.js +5 -9
- package/exceptions/gateway-timeout.exception.d.ts +1 -1
- package/exceptions/gateway-timeout.exception.js +5 -9
- package/exceptions/gone.exception.d.ts +1 -1
- package/exceptions/gone.exception.js +5 -9
- package/exceptions/http-version-not-supported.exception.d.ts +1 -1
- package/exceptions/http-version-not-supported.exception.js +5 -9
- package/exceptions/http.exception.d.ts +6 -2
- package/exceptions/http.exception.js +36 -17
- package/exceptions/im-a-teapot.exception.d.ts +1 -1
- package/exceptions/im-a-teapot.exception.js +5 -9
- package/exceptions/index.d.ts +23 -23
- package/exceptions/index.js +23 -26
- package/exceptions/internal-server-error.exception.d.ts +1 -1
- package/exceptions/internal-server-error.exception.js +5 -9
- package/exceptions/intrinsic.exception.js +1 -5
- package/exceptions/method-not-allowed.exception.d.ts +1 -1
- package/exceptions/method-not-allowed.exception.js +5 -9
- package/exceptions/misdirected.exception.d.ts +1 -1
- package/exceptions/misdirected.exception.js +5 -9
- package/exceptions/not-acceptable.exception.d.ts +1 -1
- package/exceptions/not-acceptable.exception.js +5 -9
- package/exceptions/not-found.exception.d.ts +1 -1
- package/exceptions/not-found.exception.js +5 -9
- package/exceptions/not-implemented.exception.d.ts +1 -1
- package/exceptions/not-implemented.exception.js +5 -9
- package/exceptions/payload-too-large.exception.d.ts +1 -1
- package/exceptions/payload-too-large.exception.js +5 -9
- package/exceptions/precondition-failed.exception.d.ts +1 -1
- package/exceptions/precondition-failed.exception.js +5 -9
- package/exceptions/request-timeout.exception.d.ts +1 -1
- package/exceptions/request-timeout.exception.js +5 -9
- package/exceptions/service-unavailable.exception.d.ts +1 -1
- package/exceptions/service-unavailable.exception.js +5 -9
- package/exceptions/unauthorized.exception.d.ts +1 -1
- package/exceptions/unauthorized.exception.js +5 -9
- package/exceptions/unprocessable-entity.exception.d.ts +1 -1
- package/exceptions/unprocessable-entity.exception.js +5 -9
- package/exceptions/unsupported-media-type.exception.d.ts +1 -1
- package/exceptions/unsupported-media-type.exception.js +5 -9
- package/file-stream/index.d.ts +1 -1
- package/file-stream/index.js +1 -4
- package/file-stream/interfaces/index.d.ts +2 -2
- package/file-stream/interfaces/index.js +2 -5
- package/file-stream/interfaces/streamable-handler-response.interface.js +1 -2
- package/file-stream/interfaces/streamable-options.interface.js +1 -2
- package/file-stream/streamable-file.d.ts +2 -2
- package/file-stream/streamable-file.js +26 -28
- package/index.d.ts +10 -10
- package/index.js +11 -17
- package/interfaces/abstract.interface.js +1 -2
- package/interfaces/controllers/controller-metadata.interface.js +1 -2
- package/interfaces/controllers/controller.interface.js +1 -2
- package/interfaces/controllers/index.d.ts +2 -2
- package/interfaces/controllers/index.js +2 -5
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/exception-filter.interface.js +1 -2
- package/interfaces/exceptions/index.d.ts +5 -5
- package/interfaces/exceptions/index.js +5 -8
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/rpc-exception-filter.interface.js +1 -2
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/ws-exception-filter.interface.js +1 -2
- package/interfaces/external/class-transform-options.interface.js +1 -2
- package/interfaces/external/cors-options.interface.js +1 -2
- package/interfaces/external/https-options.interface.js +1 -2
- package/interfaces/external/transformer-package.interface.d.ts +2 -2
- package/interfaces/external/transformer-package.interface.js +1 -2
- package/interfaces/external/validation-error.interface.js +1 -2
- package/interfaces/external/validator-options.interface.js +1 -2
- package/interfaces/external/validator-package.interface.d.ts +2 -2
- package/interfaces/external/validator-package.interface.js +1 -2
- package/interfaces/features/arguments-host.interface.js +1 -2
- package/interfaces/features/can-activate.interface.d.ts +1 -1
- package/interfaces/features/can-activate.interface.js +1 -2
- package/interfaces/features/custom-route-param-factory.interface.d.ts +1 -1
- package/interfaces/features/custom-route-param-factory.interface.js +1 -2
- package/interfaces/features/execution-context.interface.d.ts +2 -2
- package/interfaces/features/execution-context.interface.js +1 -2
- package/interfaces/features/nest-interceptor.interface.d.ts +1 -1
- package/interfaces/features/nest-interceptor.interface.js +1 -2
- package/interfaces/features/paramtype.interface.js +1 -2
- package/interfaces/features/pipe-transform.interface.d.ts +10 -4
- package/interfaces/features/pipe-transform.interface.js +1 -2
- package/interfaces/global-prefix-options.interface.d.ts +1 -1
- package/interfaces/global-prefix-options.interface.js +1 -2
- package/interfaces/hooks/before-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/index.d.ts +5 -5
- package/interfaces/hooks/index.js +5 -8
- package/interfaces/hooks/on-application-bootstrap.interface.js +1 -2
- package/interfaces/hooks/on-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/on-destroy.interface.js +1 -2
- package/interfaces/hooks/on-init.interface.js +1 -2
- package/interfaces/http/http-exception-body.interface.d.ts +2 -1
- package/interfaces/http/http-exception-body.interface.js +1 -2
- package/interfaces/http/http-redirect-response.interface.d.ts +1 -1
- package/interfaces/http/http-redirect-response.interface.js +1 -2
- package/interfaces/http/http-server.interface.d.ts +4 -3
- package/interfaces/http/http-server.interface.js +1 -2
- package/interfaces/http/index.d.ts +5 -5
- package/interfaces/http/index.js +5 -8
- package/interfaces/http/message-event.interface.js +1 -2
- package/interfaces/http/raw-body-request.interface.js +1 -2
- package/interfaces/index.d.ts +31 -30
- package/interfaces/index.js +31 -33
- package/interfaces/injectable.interface.js +1 -2
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +1 -2
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +1 -1
- package/interfaces/microservices/nest-microservice-options.interface.js +1 -2
- package/interfaces/microservices/pre-request-hook.interface.d.ts +22 -0
- package/interfaces/microservices/pre-request-hook.interface.js +1 -0
- package/interfaces/middleware/index.d.ts +4 -4
- package/interfaces/middleware/index.js +4 -7
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-config-proxy.interface.js +1 -2
- package/interfaces/middleware/middleware-configuration.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-configuration.interface.js +1 -2
- package/interfaces/middleware/middleware-consumer.interface.d.ts +2 -2
- package/interfaces/middleware/middleware-consumer.interface.js +1 -2
- package/interfaces/middleware/nest-middleware.interface.js +1 -2
- package/interfaces/modules/dynamic-module.interface.d.ts +2 -2
- package/interfaces/modules/dynamic-module.interface.js +1 -2
- package/interfaces/modules/forward-reference.interface.js +1 -2
- package/interfaces/modules/index.d.ts +8 -8
- package/interfaces/modules/index.js +8 -11
- package/interfaces/modules/injection-token.interface.d.ts +2 -2
- package/interfaces/modules/injection-token.interface.js +1 -2
- package/interfaces/modules/introspection-result.interface.d.ts +1 -1
- package/interfaces/modules/introspection-result.interface.js +1 -2
- package/interfaces/modules/module-metadata.interface.d.ts +5 -5
- package/interfaces/modules/module-metadata.interface.js +1 -2
- package/interfaces/modules/nest-module.interface.d.ts +1 -1
- package/interfaces/modules/nest-module.interface.js +1 -2
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +1 -1
- package/interfaces/modules/optional-factory-dependency.interface.js +1 -2
- package/interfaces/modules/provider.interface.d.ts +4 -4
- package/interfaces/modules/provider.interface.js +1 -2
- package/interfaces/nest-application-context-options.interface.d.ts +1 -1
- package/interfaces/nest-application-context-options.interface.js +55 -5
- package/interfaces/nest-application-context.interface.d.ts +6 -6
- package/interfaces/nest-application-context.interface.js +1 -2
- package/interfaces/nest-application-options.interface.d.ts +9 -3
- package/interfaces/nest-application-options.interface.js +1 -2
- package/interfaces/nest-application.interface.d.ts +8 -8
- package/interfaces/nest-application.interface.js +1 -2
- package/interfaces/nest-microservice.interface.d.ts +15 -6
- package/interfaces/nest-microservice.interface.js +1 -2
- package/interfaces/scope-options.interface.js +2 -5
- package/interfaces/shutdown-hooks-options.interface.js +1 -2
- package/interfaces/type.interface.js +1 -2
- package/interfaces/version-options.interface.d.ts +1 -1
- package/interfaces/version-options.interface.js +1 -4
- package/interfaces/websockets/web-socket-adapter.interface.js +1 -2
- package/internal.d.ts +30 -0
- package/internal.js +19 -0
- package/module-utils/configurable-module.builder.d.ts +4 -4
- package/module-utils/configurable-module.builder.js +21 -20
- package/module-utils/constants.js +5 -8
- package/module-utils/index.d.ts +2 -2
- package/module-utils/index.js +2 -5
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +3 -3
- package/module-utils/interfaces/configurable-module-cls.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-host.interface.js +1 -2
- package/module-utils/interfaces/index.d.ts +3 -3
- package/module-utils/interfaces/index.js +3 -6
- package/module-utils/utils/generate-options-injection-token.util.js +3 -6
- package/module-utils/utils/get-injection-providers.util.d.ts +1 -1
- package/module-utils/utils/get-injection-providers.util.js +4 -7
- package/module-utils/utils/index.d.ts +2 -2
- package/module-utils/utils/index.js +2 -5
- package/package.json +35 -2
- package/pipes/default-value.pipe.d.ts +1 -1
- package/pipes/default-value.pipe.js +10 -12
- package/pipes/file/file-type.validator.d.ts +3 -3
- package/pipes/file/file-type.validator.js +5 -19
- package/pipes/file/file-validator-context.interface.d.ts +1 -1
- package/pipes/file/file-validator-context.interface.js +1 -2
- package/pipes/file/file-validator.interface.d.ts +1 -1
- package/pipes/file/file-validator.interface.js +2 -5
- package/pipes/file/index.d.ts +6 -6
- package/pipes/file/index.js +6 -9
- package/pipes/file/interfaces/file.interface.js +1 -2
- package/pipes/file/interfaces/index.d.ts +1 -1
- package/pipes/file/interfaces/index.js +1 -4
- package/pipes/file/max-file-size.validator.d.ts +3 -3
- package/pipes/file/max-file-size.validator.js +2 -6
- package/pipes/file/parse-file-options.interface.d.ts +2 -2
- package/pipes/file/parse-file-options.interface.js +1 -2
- package/pipes/file/parse-file-pipe.builder.d.ts +5 -5
- package/pipes/file/parse-file-pipe.builder.js +8 -14
- package/pipes/file/parse-file.pipe.d.ts +7 -7
- package/pipes/file/parse-file.pipe.js +17 -18
- package/pipes/index.d.ts +11 -10
- package/pipes/index.js +11 -13
- package/pipes/parse-array.pipe.d.ts +4 -4
- package/pipes/parse-array.pipe.js +23 -23
- package/pipes/parse-bool.pipe.d.ts +6 -6
- package/pipes/parse-bool.pipe.js +16 -17
- package/pipes/parse-date.pipe.d.ts +4 -4
- package/pipes/parse-date.pipe.js +17 -16
- package/pipes/parse-enum.pipe.d.ts +5 -5
- package/pipes/parse-enum.pipe.js +16 -16
- package/pipes/parse-float.pipe.d.ts +6 -6
- package/pipes/parse-float.pipe.js +17 -18
- package/pipes/parse-int.pipe.d.ts +5 -5
- package/pipes/parse-int.pipe.js +18 -19
- package/pipes/parse-uuid.pipe.d.ts +4 -4
- package/pipes/parse-uuid.pipe.js +27 -26
- package/pipes/standard-schema-validation.pipe.d.ts +86 -0
- package/pipes/standard-schema-validation.pipe.js +120 -0
- package/pipes/validation.pipe.d.ts +32 -14
- package/pipes/validation.pipe.js +60 -30
- package/serializer/class-serializer.constants.js +1 -4
- package/serializer/class-serializer.interceptor.d.ts +5 -5
- package/serializer/class-serializer.interceptor.js +21 -24
- package/serializer/class-serializer.interfaces.d.ts +2 -2
- package/serializer/class-serializer.interfaces.js +1 -2
- package/serializer/decorators/index.d.ts +1 -1
- package/serializer/decorators/index.js +1 -4
- package/serializer/decorators/serialize-options.decorator.d.ts +3 -2
- package/serializer/decorators/serialize-options.decorator.js +3 -7
- package/serializer/index.d.ts +5 -3
- package/serializer/index.js +5 -6
- package/serializer/standard-schema-serializer.interceptor.d.ts +50 -0
- package/serializer/standard-schema-serializer.interceptor.js +75 -0
- package/serializer/standard-schema-serializer.interfaces.d.ts +18 -0
- package/serializer/standard-schema-serializer.interfaces.js +1 -0
- package/services/console-logger.service.d.ts +22 -3
- package/services/console-logger.service.js +132 -66
- package/services/index.d.ts +3 -3
- package/services/index.js +3 -6
- package/services/logger.service.js +86 -83
- package/services/utils/filter-log-levels.util.d.ts +1 -1
- package/services/utils/filter-log-levels.util.js +7 -10
- package/services/utils/index.d.ts +3 -3
- package/services/utils/index.js +3 -6
- package/services/utils/is-log-level-enabled.util.d.ts +1 -1
- package/services/utils/is-log-level-enabled.util.js +1 -4
- package/services/utils/is-log-level.util.d.ts +1 -1
- package/services/utils/is-log-level.util.js +3 -6
- package/tsconfig.build.json +1 -2
- package/utils/assign-custom-metadata.util.d.ts +5 -4
- package/utils/assign-custom-metadata.util.js +4 -6
- package/utils/cli-colors.util.js +4 -8
- package/utils/extend-metadata.util.js +1 -4
- package/utils/forward-ref.util.d.ts +1 -1
- package/utils/forward-ref.util.js +1 -5
- package/utils/http-error-by-code.util.d.ts +2 -2
- package/utils/http-error-by-code.util.js +22 -25
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -4
- package/utils/load-package.util.d.ts +29 -1
- package/utils/load-package.util.js +84 -9
- package/utils/merge-with-values.util.js +1 -5
- package/utils/random-string-generator.util.js +2 -6
- package/utils/select-exception-filter-metadata.util.d.ts +1 -1
- package/utils/select-exception-filter-metadata.util.js +1 -5
- package/utils/shared.utils.d.ts +11 -10
- package/utils/shared.utils.js +28 -30
- package/utils/validate-each.util.js +3 -7
- package/utils/validate-module-keys.util.js +8 -13
package/constants.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ENTRY_PROVIDER_WATERMARK = exports.CATCH_WATERMARK = exports.CONTROLLER_WATERMARK = exports.INJECTABLE_WATERMARK = exports.VERSION_METADATA = exports.SSE_METADATA = exports.RESPONSE_PASSTHROUGH_METADATA = exports.REDIRECT_METADATA = exports.HEADERS_METADATA = exports.MODULE_PATH = exports.HTTP_CODE_METADATA = exports.RENDER_METADATA = exports.ENHANCER_KEY_TO_SUBTYPE_MAP = exports.EXCEPTION_FILTERS_METADATA = exports.INTERCEPTORS_METADATA = exports.GUARDS_METADATA = exports.PIPES_METADATA = exports.FILTER_CATCH_EXCEPTIONS = exports.CUSTOM_ROUTE_ARGS_METADATA = exports.ROUTE_ARGS_METADATA = exports.METHOD_METADATA = exports.SCOPE_OPTIONS_METADATA = exports.OPTIONAL_PROPERTY_DEPS_METADATA = exports.PROPERTY_DEPS_METADATA = exports.OPTIONAL_DEPS_METADATA = exports.SELF_DECLARED_DEPS_METADATA = exports.PARAMTYPES_METADATA = exports.PATH_METADATA = exports.HOST_METADATA = exports.GLOBAL_MODULE_METADATA = exports.MODULE_METADATA = void 0;
|
|
4
|
-
exports.MODULE_METADATA = {
|
|
1
|
+
export const MODULE_METADATA = {
|
|
5
2
|
IMPORTS: 'imports',
|
|
6
3
|
PROVIDERS: 'providers',
|
|
7
4
|
CONTROLLERS: 'controllers',
|
|
8
5
|
EXPORTS: 'exports',
|
|
9
6
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
[
|
|
29
|
-
[
|
|
30
|
-
[
|
|
31
|
-
[
|
|
7
|
+
export const GLOBAL_MODULE_METADATA = '__module:global__';
|
|
8
|
+
export const HOST_METADATA = 'host';
|
|
9
|
+
export const PATH_METADATA = 'path';
|
|
10
|
+
export const PARAMTYPES_METADATA = 'design:paramtypes';
|
|
11
|
+
export const SELF_DECLARED_DEPS_METADATA = 'self:paramtypes';
|
|
12
|
+
export const OPTIONAL_DEPS_METADATA = 'optional:paramtypes';
|
|
13
|
+
export const PROPERTY_DEPS_METADATA = 'self:properties_metadata';
|
|
14
|
+
export const OPTIONAL_PROPERTY_DEPS_METADATA = 'optional:properties_metadata';
|
|
15
|
+
export const SCOPE_OPTIONS_METADATA = 'scope:options';
|
|
16
|
+
export const METHOD_METADATA = 'method';
|
|
17
|
+
export const ROUTE_ARGS_METADATA = '__routeArguments__';
|
|
18
|
+
export const CUSTOM_ROUTE_ARGS_METADATA = '__customRouteArgs__';
|
|
19
|
+
export const FILTER_CATCH_EXCEPTIONS = '__filterCatchExceptions__';
|
|
20
|
+
export const PIPES_METADATA = '__pipes__';
|
|
21
|
+
export const GUARDS_METADATA = '__guards__';
|
|
22
|
+
export const INTERCEPTORS_METADATA = '__interceptors__';
|
|
23
|
+
export const EXCEPTION_FILTERS_METADATA = '__exceptionFilters__';
|
|
24
|
+
export const ENHANCER_KEY_TO_SUBTYPE_MAP = {
|
|
25
|
+
[GUARDS_METADATA]: 'guard',
|
|
26
|
+
[INTERCEPTORS_METADATA]: 'interceptor',
|
|
27
|
+
[PIPES_METADATA]: 'pipe',
|
|
28
|
+
[EXCEPTION_FILTERS_METADATA]: 'filter',
|
|
32
29
|
};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
export const RENDER_METADATA = '__renderTemplate__';
|
|
31
|
+
export const HTTP_CODE_METADATA = '__httpCode__';
|
|
32
|
+
export const MODULE_PATH = '__module_path__';
|
|
33
|
+
export const HEADERS_METADATA = '__headers__';
|
|
34
|
+
export const REDIRECT_METADATA = '__redirect__';
|
|
35
|
+
export const RESPONSE_PASSTHROUGH_METADATA = '__responsePassthrough__';
|
|
36
|
+
export const SSE_METADATA = '__sse__';
|
|
37
|
+
export const VERSION_METADATA = '__version__';
|
|
38
|
+
export const INJECTABLE_WATERMARK = '__injectable__';
|
|
39
|
+
export const CONTROLLER_WATERMARK = '__controller__';
|
|
40
|
+
export const CATCH_WATERMARK = '__catch__';
|
|
41
|
+
export const ENTRY_PROVIDER_WATERMARK = '__entryProvider__';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.applyDecorators = applyDecorators;
|
|
4
1
|
/**
|
|
5
2
|
* Function that returns a new decorator that applies all decorators provided by param
|
|
6
3
|
*
|
|
@@ -10,7 +7,7 @@ exports.applyDecorators = applyDecorators;
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
function applyDecorators(...decorators) {
|
|
10
|
+
export function applyDecorators(...decorators) {
|
|
14
11
|
return (target, propertyKey, descriptor) => {
|
|
15
12
|
for (const decorator of decorators) {
|
|
16
13
|
if (target instanceof Function && !descriptor) {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Bind = Bind;
|
|
4
1
|
/**
|
|
5
2
|
* Decorator that binds *parameter decorators* to the method that follows.
|
|
6
3
|
*
|
|
@@ -11,7 +8,7 @@ exports.Bind = Bind;
|
|
|
11
8
|
*
|
|
12
9
|
* @publicApi
|
|
13
10
|
*/
|
|
14
|
-
function Bind(...decorators) {
|
|
11
|
+
export function Bind(...decorators) {
|
|
15
12
|
return (target, key, descriptor) => {
|
|
16
13
|
decorators.forEach((fn, index) => fn(target, key, index));
|
|
17
14
|
return descriptor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type, Abstract } from '../../interfaces';
|
|
1
|
+
import { Type, Abstract } from '../../interfaces/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a class as a Nest exception filter. An exception filter
|
|
4
4
|
* handles exceptions thrown by or not handled by your application code.
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Catch = Catch;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { CATCH_WATERMARK, FILTER_CATCH_EXCEPTIONS } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Decorator that marks a class as a Nest exception filter. An exception filter
|
|
7
4
|
* handles exceptions thrown by or not handled by your application code.
|
|
@@ -19,9 +16,9 @@ const constants_1 = require("../../constants");
|
|
|
19
16
|
*
|
|
20
17
|
* @publicApi
|
|
21
18
|
*/
|
|
22
|
-
function Catch(...exceptions) {
|
|
19
|
+
export function Catch(...exceptions) {
|
|
23
20
|
return (target) => {
|
|
24
|
-
Reflect.defineMetadata(
|
|
25
|
-
Reflect.defineMetadata(
|
|
21
|
+
Reflect.defineMetadata(CATCH_WATERMARK, true, target);
|
|
22
|
+
Reflect.defineMetadata(FILTER_CATCH_EXCEPTIONS, exceptions, target);
|
|
26
23
|
};
|
|
27
24
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Controller = Controller;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
1
|
+
import { CONTROLLER_WATERMARK, HOST_METADATA, PATH_METADATA, SCOPE_OPTIONS_METADATA, VERSION_METADATA, } from '../../constants.js';
|
|
2
|
+
import { isString, isUndefined } from '../../utils/shared.utils.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a class as a Nest controller that can receive inbound
|
|
8
5
|
* requests and produce responses.
|
|
@@ -37,11 +34,11 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
37
34
|
*
|
|
38
35
|
* @publicApi
|
|
39
36
|
*/
|
|
40
|
-
function Controller(prefixOrOptions) {
|
|
37
|
+
export function Controller(prefixOrOptions) {
|
|
41
38
|
const defaultPath = '/';
|
|
42
|
-
const [path, host, scopeOptions, versionOptions] =
|
|
39
|
+
const [path, host, scopeOptions, versionOptions] = isUndefined(prefixOrOptions)
|
|
43
40
|
? [defaultPath, undefined, undefined, undefined]
|
|
44
|
-
:
|
|
41
|
+
: isString(prefixOrOptions) || Array.isArray(prefixOrOptions)
|
|
45
42
|
? [prefixOrOptions, undefined, undefined, undefined]
|
|
46
43
|
: [
|
|
47
44
|
prefixOrOptions.path || defaultPath,
|
|
@@ -52,10 +49,10 @@ function Controller(prefixOrOptions) {
|
|
|
52
49
|
: prefixOrOptions.version,
|
|
53
50
|
];
|
|
54
51
|
return (target) => {
|
|
55
|
-
Reflect.defineMetadata(
|
|
56
|
-
Reflect.defineMetadata(
|
|
57
|
-
Reflect.defineMetadata(
|
|
58
|
-
Reflect.defineMetadata(
|
|
59
|
-
Reflect.defineMetadata(
|
|
52
|
+
Reflect.defineMetadata(CONTROLLER_WATERMARK, true, target);
|
|
53
|
+
Reflect.defineMetadata(PATH_METADATA, path, target);
|
|
54
|
+
Reflect.defineMetadata(HOST_METADATA, host, target);
|
|
55
|
+
Reflect.defineMetadata(SCOPE_OPTIONS_METADATA, scopeOptions, target);
|
|
56
|
+
Reflect.defineMetadata(VERSION_METADATA, versionOptions, target);
|
|
60
57
|
};
|
|
61
58
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Dependencies = void 0;
|
|
4
|
-
exports.flatten = flatten;
|
|
5
|
-
const constants_1 = require("../../constants");
|
|
6
|
-
function flatten(arr) {
|
|
1
|
+
import { PARAMTYPES_METADATA } from '../../constants.js';
|
|
2
|
+
export function flatten(arr) {
|
|
7
3
|
const flat = [].concat(...arr);
|
|
8
4
|
return flat.some(Array.isArray)
|
|
9
5
|
? flatten(flat)
|
|
@@ -14,10 +10,9 @@ function flatten(arr) {
|
|
|
14
10
|
*
|
|
15
11
|
* @publicApi
|
|
16
12
|
*/
|
|
17
|
-
const Dependencies = (...dependencies) => {
|
|
13
|
+
export const Dependencies = (...dependencies) => {
|
|
18
14
|
const flattenDeps = flatten(dependencies);
|
|
19
15
|
return (target) => {
|
|
20
|
-
Reflect.defineMetadata(
|
|
16
|
+
Reflect.defineMetadata(PARAMTYPES_METADATA, flattenDeps, target);
|
|
21
17
|
};
|
|
22
18
|
};
|
|
23
|
-
exports.Dependencies = Dependencies;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
1
|
+
import { EXCEPTION_FILTERS_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
3
|
+
import { isFunction } from '../../utils/shared.utils.js';
|
|
4
|
+
import { validateEach } from '../../utils/validate-each.util.js';
|
|
8
5
|
/**
|
|
9
6
|
* Decorator that binds exception filters to the scope of the controller or
|
|
10
7
|
* method, depending on its context.
|
|
@@ -26,18 +23,17 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
26
23
|
*
|
|
27
24
|
* @publicApi
|
|
28
25
|
*/
|
|
29
|
-
const UseFilters = (...filters) => addExceptionFiltersMetadata(...filters);
|
|
30
|
-
exports.UseFilters = UseFilters;
|
|
26
|
+
export const UseFilters = (...filters) => addExceptionFiltersMetadata(...filters);
|
|
31
27
|
function addExceptionFiltersMetadata(...filters) {
|
|
32
28
|
return (target, key, descriptor) => {
|
|
33
|
-
const isFilterValid = (filter) => filter && (
|
|
29
|
+
const isFilterValid = (filter) => filter && (isFunction(filter) || isFunction(filter.catch));
|
|
34
30
|
if (descriptor) {
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
validateEach(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
|
|
32
|
+
extendArrayMetadata(EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
|
|
37
33
|
return descriptor;
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
validateEach(target, filters, isFilterValid, '@UseFilters', 'filter');
|
|
36
|
+
extendArrayMetadata(EXCEPTION_FILTERS_METADATA, filters, target);
|
|
41
37
|
return target;
|
|
42
38
|
};
|
|
43
39
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export * from './bind.decorator';
|
|
2
|
-
export * from './catch.decorator';
|
|
3
|
-
export * from './controller.decorator';
|
|
4
|
-
export * from './dependencies.decorator';
|
|
5
|
-
export * from './exception-filters.decorator';
|
|
6
|
-
export * from './inject.decorator';
|
|
7
|
-
export * from './injectable.decorator';
|
|
8
|
-
export * from './optional.decorator';
|
|
9
|
-
export * from './set-metadata.decorator';
|
|
10
|
-
export * from './use-guards.decorator';
|
|
11
|
-
export * from './use-interceptors.decorator';
|
|
12
|
-
export * from './use-pipes.decorator';
|
|
13
|
-
export * from './apply-decorators';
|
|
14
|
-
export * from './version.decorator';
|
|
1
|
+
export * from './bind.decorator.js';
|
|
2
|
+
export * from './catch.decorator.js';
|
|
3
|
+
export * from './controller.decorator.js';
|
|
4
|
+
export * from './dependencies.decorator.js';
|
|
5
|
+
export * from './exception-filters.decorator.js';
|
|
6
|
+
export * from './inject.decorator.js';
|
|
7
|
+
export * from './injectable.decorator.js';
|
|
8
|
+
export * from './optional.decorator.js';
|
|
9
|
+
export * from './set-metadata.decorator.js';
|
|
10
|
+
export * from './use-guards.decorator.js';
|
|
11
|
+
export * from './use-interceptors.decorator.js';
|
|
12
|
+
export * from './use-pipes.decorator.js';
|
|
13
|
+
export * from './apply-decorators.js';
|
|
14
|
+
export * from './version.decorator.js';
|
package/decorators/core/index.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
tslib_1.__exportStar(require("./use-pipes.decorator"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./apply-decorators"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./version.decorator"), exports);
|
|
1
|
+
export * from './bind.decorator.js';
|
|
2
|
+
export * from './catch.decorator.js';
|
|
3
|
+
export * from './controller.decorator.js';
|
|
4
|
+
export * from './dependencies.decorator.js';
|
|
5
|
+
export * from './exception-filters.decorator.js';
|
|
6
|
+
export * from './inject.decorator.js';
|
|
7
|
+
export * from './injectable.decorator.js';
|
|
8
|
+
export * from './optional.decorator.js';
|
|
9
|
+
export * from './set-metadata.decorator.js';
|
|
10
|
+
export * from './use-guards.decorator.js';
|
|
11
|
+
export * from './use-interceptors.decorator.js';
|
|
12
|
+
export * from './use-pipes.decorator.js';
|
|
13
|
+
export * from './apply-decorators.js';
|
|
14
|
+
export * from './version.decorator.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ForwardReference, InjectionToken } from '../../interfaces';
|
|
1
|
+
import { ForwardReference, InjectionToken } from '../../interfaces/index.js';
|
|
2
2
|
/**
|
|
3
3
|
* Decorator that marks a constructor parameter as a target for
|
|
4
4
|
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Inject = Inject;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
1
|
+
import { PARAMTYPES_METADATA, PROPERTY_DEPS_METADATA, SELF_DECLARED_DEPS_METADATA, } from '../../constants.js';
|
|
2
|
+
import { isUndefined } from '../../utils/shared.utils.js';
|
|
6
3
|
/**
|
|
7
4
|
* Decorator that marks a constructor parameter as a target for
|
|
8
5
|
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
|
|
@@ -32,22 +29,22 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
32
29
|
*
|
|
33
30
|
* @publicApi
|
|
34
31
|
*/
|
|
35
|
-
function Inject(token) {
|
|
32
|
+
export function Inject(token) {
|
|
36
33
|
const injectCallHasArguments = arguments.length > 0;
|
|
37
34
|
return (target, key, index) => {
|
|
38
35
|
let type = token || Reflect.getMetadata('design:type', target, key);
|
|
39
36
|
// Try to infer the token in a constructor-based injection
|
|
40
37
|
if (!type && !injectCallHasArguments) {
|
|
41
|
-
type = Reflect.getMetadata(
|
|
38
|
+
type = Reflect.getMetadata(PARAMTYPES_METADATA, target, key)?.[index];
|
|
42
39
|
}
|
|
43
|
-
if (!
|
|
44
|
-
let dependencies = Reflect.getMetadata(
|
|
40
|
+
if (!isUndefined(index)) {
|
|
41
|
+
let dependencies = Reflect.getMetadata(SELF_DECLARED_DEPS_METADATA, target) || [];
|
|
45
42
|
dependencies = [...dependencies, { index, param: type }];
|
|
46
|
-
Reflect.defineMetadata(
|
|
43
|
+
Reflect.defineMetadata(SELF_DECLARED_DEPS_METADATA, dependencies, target);
|
|
47
44
|
return;
|
|
48
45
|
}
|
|
49
|
-
let properties = Reflect.getMetadata(
|
|
46
|
+
let properties = Reflect.getMetadata(PROPERTY_DEPS_METADATA, target.constructor) || [];
|
|
50
47
|
properties = [...properties, { key, type }];
|
|
51
|
-
Reflect.defineMetadata(
|
|
48
|
+
Reflect.defineMetadata(PROPERTY_DEPS_METADATA, properties, target.constructor);
|
|
52
49
|
};
|
|
53
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScopeOptions } from '../../interfaces/scope-options.interface';
|
|
2
|
-
import { Type } from '../../interfaces/type.interface';
|
|
1
|
+
import { ScopeOptions } from '../../interfaces/scope-options.interface.js';
|
|
2
|
+
import { Type } from '../../interfaces/type.interface.js';
|
|
3
3
|
/**
|
|
4
4
|
* Defines the injection scope.
|
|
5
5
|
*
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Injectable = Injectable;
|
|
4
|
-
exports.mixin = mixin;
|
|
5
|
-
const uid_1 = require("uid");
|
|
6
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { uid } from 'uid';
|
|
2
|
+
import { INJECTABLE_WATERMARK, SCOPE_OPTIONS_METADATA, } from '../../constants.js';
|
|
7
3
|
/**
|
|
8
4
|
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
9
5
|
* Providers can be injected into other classes via constructor parameter injection
|
|
@@ -32,18 +28,18 @@ const constants_1 = require("../../constants");
|
|
|
32
28
|
*
|
|
33
29
|
* @publicApi
|
|
34
30
|
*/
|
|
35
|
-
function Injectable(options) {
|
|
31
|
+
export function Injectable(options) {
|
|
36
32
|
return (target) => {
|
|
37
|
-
Reflect.defineMetadata(
|
|
38
|
-
Reflect.defineMetadata(
|
|
33
|
+
Reflect.defineMetadata(INJECTABLE_WATERMARK, true, target);
|
|
34
|
+
Reflect.defineMetadata(SCOPE_OPTIONS_METADATA, options, target);
|
|
39
35
|
};
|
|
40
36
|
}
|
|
41
37
|
/**
|
|
42
38
|
* @publicApi
|
|
43
39
|
*/
|
|
44
|
-
function mixin(mixinClass) {
|
|
40
|
+
export function mixin(mixinClass) {
|
|
45
41
|
Object.defineProperty(mixinClass, 'name', {
|
|
46
|
-
value:
|
|
42
|
+
value: uid(21),
|
|
47
43
|
});
|
|
48
44
|
Injectable()(mixinClass);
|
|
49
45
|
return mixinClass;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Optional = Optional;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const shared_utils_1 = require("../../utils/shared.utils");
|
|
1
|
+
import { OPTIONAL_DEPS_METADATA, OPTIONAL_PROPERTY_DEPS_METADATA, } from '../../constants.js';
|
|
2
|
+
import { isUndefined } from '../../utils/shared.utils.js';
|
|
6
3
|
/**
|
|
7
4
|
* Parameter decorator for an injected dependency marking the
|
|
8
5
|
* dependency as optional.
|
|
@@ -16,14 +13,14 @@ const shared_utils_1 = require("../../utils/shared.utils");
|
|
|
16
13
|
*
|
|
17
14
|
* @publicApi
|
|
18
15
|
*/
|
|
19
|
-
function Optional() {
|
|
16
|
+
export function Optional() {
|
|
20
17
|
return (target, key, index) => {
|
|
21
|
-
if (!
|
|
22
|
-
const args = Reflect.getMetadata(
|
|
23
|
-
Reflect.defineMetadata(
|
|
18
|
+
if (!isUndefined(index)) {
|
|
19
|
+
const args = Reflect.getMetadata(OPTIONAL_DEPS_METADATA, target) || [];
|
|
20
|
+
Reflect.defineMetadata(OPTIONAL_DEPS_METADATA, [...args, index], target);
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
|
-
const properties = Reflect.getMetadata(
|
|
27
|
-
Reflect.defineMetadata(
|
|
23
|
+
const properties = Reflect.getMetadata(OPTIONAL_PROPERTY_DEPS_METADATA, target.constructor) || [];
|
|
24
|
+
Reflect.defineMetadata(OPTIONAL_PROPERTY_DEPS_METADATA, [...properties, key], target.constructor);
|
|
28
25
|
};
|
|
29
26
|
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SetMetadata = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Decorator that assigns metadata to the class/function using the
|
|
6
3
|
* specified `key`.
|
|
@@ -17,7 +14,7 @@ exports.SetMetadata = void 0;
|
|
|
17
14
|
*
|
|
18
15
|
* @publicApi
|
|
19
16
|
*/
|
|
20
|
-
const SetMetadata = (metadataKey, metadataValue) => {
|
|
17
|
+
export const SetMetadata = (metadataKey, metadataValue) => {
|
|
21
18
|
const decoratorFactory = (target, key, descriptor) => {
|
|
22
19
|
if (descriptor) {
|
|
23
20
|
Reflect.defineMetadata(metadataKey, metadataValue, descriptor.value);
|
|
@@ -29,4 +26,3 @@ const SetMetadata = (metadataKey, metadataValue) => {
|
|
|
29
26
|
decoratorFactory.KEY = metadataKey;
|
|
30
27
|
return decoratorFactory;
|
|
31
28
|
};
|
|
32
|
-
exports.SetMetadata = SetMetadata;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
1
|
+
import { GUARDS_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
3
|
+
import { isFunction } from '../../utils/shared.utils.js';
|
|
4
|
+
import { validateEach } from '../../utils/validate-each.util.js';
|
|
8
5
|
/**
|
|
9
6
|
* Decorator that binds guards to the scope of the controller or method,
|
|
10
7
|
* depending on its context.
|
|
@@ -26,16 +23,16 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
26
23
|
*
|
|
27
24
|
* @publicApi
|
|
28
25
|
*/
|
|
29
|
-
function UseGuards(...guards) {
|
|
26
|
+
export function UseGuards(...guards) {
|
|
30
27
|
return (target, key, descriptor) => {
|
|
31
|
-
const isGuardValid = (guard) => guard && (
|
|
28
|
+
const isGuardValid = (guard) => guard && (isFunction(guard) || isFunction(guard.canActivate));
|
|
32
29
|
if (descriptor) {
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
validateEach(target.constructor, guards, isGuardValid, '@UseGuards', 'guard');
|
|
31
|
+
extendArrayMetadata(GUARDS_METADATA, guards, descriptor.value);
|
|
35
32
|
return descriptor;
|
|
36
33
|
}
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
validateEach(target, guards, isGuardValid, '@UseGuards', 'guard');
|
|
35
|
+
extendArrayMetadata(GUARDS_METADATA, guards, target);
|
|
39
36
|
return target;
|
|
40
37
|
};
|
|
41
38
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
1
|
+
import { INTERCEPTORS_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
3
|
+
import { isFunction } from '../../utils/shared.utils.js';
|
|
4
|
+
import { validateEach } from '../../utils/validate-each.util.js';
|
|
8
5
|
/**
|
|
9
6
|
* Decorator that binds interceptors to the scope of the controller or method,
|
|
10
7
|
* depending on its context.
|
|
@@ -26,17 +23,17 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
26
23
|
*
|
|
27
24
|
* @publicApi
|
|
28
25
|
*/
|
|
29
|
-
function UseInterceptors(...interceptors) {
|
|
26
|
+
export function UseInterceptors(...interceptors) {
|
|
30
27
|
return (target, key, descriptor) => {
|
|
31
28
|
const isInterceptorValid = (interceptor) => interceptor &&
|
|
32
|
-
(
|
|
29
|
+
(isFunction(interceptor) || isFunction(interceptor.intercept));
|
|
33
30
|
if (descriptor) {
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
validateEach(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
32
|
+
extendArrayMetadata(INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
|
36
33
|
return descriptor;
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
validateEach(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
36
|
+
extendArrayMetadata(INTERCEPTORS_METADATA, interceptors, target);
|
|
40
37
|
return target;
|
|
41
38
|
};
|
|
42
39
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
1
|
+
import { PIPES_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
3
|
+
import { isFunction } from '../../utils/shared.utils.js';
|
|
4
|
+
import { validateEach } from '../../utils/validate-each.util.js';
|
|
8
5
|
/**
|
|
9
6
|
* Decorator that binds pipes to the scope of the controller or method,
|
|
10
7
|
* depending on its context.
|
|
@@ -26,15 +23,15 @@ const validate_each_util_1 = require("../../utils/validate-each.util");
|
|
|
26
23
|
*
|
|
27
24
|
* @publicApi
|
|
28
25
|
*/
|
|
29
|
-
function UsePipes(...pipes) {
|
|
26
|
+
export function UsePipes(...pipes) {
|
|
30
27
|
return (target, key, descriptor) => {
|
|
31
|
-
const isPipeValid = (pipe) => pipe && (
|
|
28
|
+
const isPipeValid = (pipe) => pipe && (isFunction(pipe) || isFunction(pipe.transform));
|
|
32
29
|
if (descriptor) {
|
|
33
|
-
|
|
30
|
+
extendArrayMetadata(PIPES_METADATA, pipes, descriptor.value);
|
|
34
31
|
return descriptor;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
validateEach(target, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
34
|
+
extendArrayMetadata(PIPES_METADATA, pipes, target);
|
|
38
35
|
return target;
|
|
39
36
|
};
|
|
40
37
|
}
|