@depup/nestjs__common 11.1.16-depup.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/LICENSE +22 -0
- package/PACKAGE.md +1 -0
- package/Readme.md +31 -0
- package/changes.json +10 -0
- package/constants.d.ts +42 -0
- package/constants.js +44 -0
- package/decorators/core/apply-decorators.d.ts +10 -0
- package/decorators/core/apply-decorators.js +23 -0
- package/decorators/core/bind.decorator.d.ts +11 -0
- package/decorators/core/bind.decorator.js +19 -0
- package/decorators/core/catch.decorator.d.ts +19 -0
- package/decorators/core/catch.decorator.js +27 -0
- package/decorators/core/controller.decorator.d.ts +102 -0
- package/decorators/core/controller.decorator.js +61 -0
- package/decorators/core/dependencies.decorator.d.ts +7 -0
- package/decorators/core/dependencies.decorator.js +23 -0
- package/decorators/core/exception-filters.decorator.d.ts +23 -0
- package/decorators/core/exception-filters.decorator.js +43 -0
- package/decorators/core/index.d.ts +14 -0
- package/decorators/core/index.js +17 -0
- package/decorators/core/inject.decorator.d.ts +31 -0
- package/decorators/core/inject.decorator.js +53 -0
- package/decorators/core/injectable.decorator.d.ts +43 -0
- package/decorators/core/injectable.decorator.js +50 -0
- package/decorators/core/optional.decorator.d.ts +14 -0
- package/decorators/core/optional.decorator.js +29 -0
- package/decorators/core/set-metadata.decorator.d.ts +20 -0
- package/decorators/core/set-metadata.decorator.js +32 -0
- package/decorators/core/use-guards.decorator.d.ts +23 -0
- package/decorators/core/use-guards.decorator.js +41 -0
- package/decorators/core/use-interceptors.decorator.d.ts +23 -0
- package/decorators/core/use-interceptors.decorator.js +42 -0
- package/decorators/core/use-pipes.decorator.d.ts +23 -0
- package/decorators/core/use-pipes.decorator.js +40 -0
- package/decorators/core/version.decorator.d.ts +7 -0
- package/decorators/core/version.decorator.js +19 -0
- package/decorators/http/create-route-param-metadata.decorator.d.ts +13 -0
- package/decorators/http/create-route-param-metadata.decorator.js +32 -0
- package/decorators/http/header.decorator.d.ts +15 -0
- package/decorators/http/header.decorator.js +25 -0
- package/decorators/http/http-code.decorator.d.ts +11 -0
- package/decorators/http/http-code.decorator.js +20 -0
- package/decorators/http/index.d.ts +8 -0
- package/decorators/http/index.js +11 -0
- package/decorators/http/redirect.decorator.d.ts +6 -0
- package/decorators/http/redirect.decorator.js +15 -0
- package/decorators/http/render.decorator.d.ts +12 -0
- package/decorators/http/render.decorator.js +21 -0
- package/decorators/http/request-mapping.decorator.d.ts +134 -0
- package/decorators/http/request-mapping.decorator.js +154 -0
- package/decorators/http/route-params.decorator.d.ts +445 -0
- package/decorators/http/route-params.decorator.js +265 -0
- package/decorators/http/sse.decorator.d.ts +10 -0
- package/decorators/http/sse.decorator.js +21 -0
- package/decorators/index.d.ts +3 -0
- package/decorators/index.js +6 -0
- package/decorators/modules/global.decorator.d.ts +12 -0
- package/decorators/modules/global.decorator.js +20 -0
- package/decorators/modules/index.d.ts +2 -0
- package/decorators/modules/index.js +5 -0
- package/decorators/modules/module.decorator.d.ts +16 -0
- package/decorators/modules/module.decorator.js +29 -0
- package/enums/http-status.enum.d.ts +60 -0
- package/enums/http-status.enum.js +64 -0
- package/enums/index.d.ts +4 -0
- package/enums/index.js +7 -0
- package/enums/request-method.enum.d.ts +18 -0
- package/enums/request-method.enum.js +22 -0
- package/enums/route-paramtypes.enum.d.ts +16 -0
- package/enums/route-paramtypes.enum.js +20 -0
- package/enums/shutdown-signal.enum.d.ts +16 -0
- package/enums/shutdown-signal.enum.js +20 -0
- package/enums/version-type.enum.d.ts +9 -0
- package/enums/version-type.enum.js +13 -0
- package/exceptions/bad-gateway.exception.d.ts +35 -0
- package/exceptions/bad-gateway.exception.js +43 -0
- package/exceptions/bad-request.exception.d.ts +35 -0
- package/exceptions/bad-request.exception.js +43 -0
- package/exceptions/conflict.exception.d.ts +35 -0
- package/exceptions/conflict.exception.js +43 -0
- package/exceptions/forbidden.exception.d.ts +35 -0
- package/exceptions/forbidden.exception.js +43 -0
- package/exceptions/gateway-timeout.exception.d.ts +35 -0
- package/exceptions/gateway-timeout.exception.js +43 -0
- package/exceptions/gone.exception.d.ts +35 -0
- package/exceptions/gone.exception.js +43 -0
- package/exceptions/http-version-not-supported.exception.d.ts +35 -0
- package/exceptions/http-version-not-supported.exception.js +43 -0
- package/exceptions/http.exception.d.ts +85 -0
- package/exceptions/http.exception.js +133 -0
- package/exceptions/im-a-teapot.exception.d.ts +38 -0
- package/exceptions/im-a-teapot.exception.js +46 -0
- package/exceptions/index.d.ts +23 -0
- package/exceptions/index.js +26 -0
- package/exceptions/internal-server-error.exception.d.ts +35 -0
- package/exceptions/internal-server-error.exception.js +43 -0
- package/exceptions/intrinsic.exception.d.ts +8 -0
- package/exceptions/intrinsic.exception.js +12 -0
- package/exceptions/method-not-allowed.exception.d.ts +35 -0
- package/exceptions/method-not-allowed.exception.js +43 -0
- package/exceptions/misdirected.exception.d.ts +35 -0
- package/exceptions/misdirected.exception.js +43 -0
- package/exceptions/not-acceptable.exception.d.ts +35 -0
- package/exceptions/not-acceptable.exception.js +43 -0
- package/exceptions/not-found.exception.d.ts +35 -0
- package/exceptions/not-found.exception.js +43 -0
- package/exceptions/not-implemented.exception.d.ts +35 -0
- package/exceptions/not-implemented.exception.js +43 -0
- package/exceptions/payload-too-large.exception.d.ts +35 -0
- package/exceptions/payload-too-large.exception.js +43 -0
- package/exceptions/precondition-failed.exception.d.ts +35 -0
- package/exceptions/precondition-failed.exception.js +43 -0
- package/exceptions/request-timeout.exception.d.ts +35 -0
- package/exceptions/request-timeout.exception.js +43 -0
- package/exceptions/service-unavailable.exception.d.ts +35 -0
- package/exceptions/service-unavailable.exception.js +43 -0
- package/exceptions/unauthorized.exception.d.ts +35 -0
- package/exceptions/unauthorized.exception.js +43 -0
- package/exceptions/unprocessable-entity.exception.d.ts +35 -0
- package/exceptions/unprocessable-entity.exception.js +43 -0
- package/exceptions/unsupported-media-type.exception.d.ts +35 -0
- package/exceptions/unsupported-media-type.exception.js +43 -0
- package/file-stream/index.d.ts +1 -0
- package/file-stream/index.js +4 -0
- package/file-stream/interfaces/index.d.ts +2 -0
- package/file-stream/interfaces/index.js +5 -0
- package/file-stream/interfaces/streamable-handler-response.interface.d.ts +12 -0
- package/file-stream/interfaces/streamable-handler-response.interface.js +2 -0
- package/file-stream/interfaces/streamable-options.interface.d.ts +22 -0
- package/file-stream/interfaces/streamable-options.interface.js +2 -0
- package/file-stream/streamable-file.d.ts +27 -0
- package/file-stream/streamable-file.js +68 -0
- package/index.d.ts +11 -0
- package/index.js +23 -0
- package/interfaces/abstract.interface.d.ts +3 -0
- package/interfaces/abstract.interface.js +2 -0
- package/interfaces/controllers/controller-metadata.interface.d.ts +3 -0
- package/interfaces/controllers/controller-metadata.interface.js +2 -0
- package/interfaces/controllers/controller.interface.d.ts +1 -0
- package/interfaces/controllers/controller.interface.js +2 -0
- package/interfaces/controllers/index.d.ts +2 -0
- package/interfaces/controllers/index.js +5 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/exception-filter.interface.js +2 -0
- package/interfaces/exceptions/index.d.ts +5 -0
- package/interfaces/exceptions/index.js +8 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +6 -0
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +2 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +19 -0
- package/interfaces/exceptions/rpc-exception-filter.interface.js +2 -0
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +18 -0
- package/interfaces/exceptions/ws-exception-filter.interface.js +2 -0
- package/interfaces/external/class-transform-options.interface.d.ts +65 -0
- package/interfaces/external/class-transform-options.interface.js +2 -0
- package/interfaces/external/cors-options.interface.d.ts +58 -0
- package/interfaces/external/cors-options.interface.js +2 -0
- package/interfaces/external/https-options.interface.d.ts +105 -0
- package/interfaces/external/https-options.interface.js +2 -0
- package/interfaces/external/transformer-package.interface.d.ts +6 -0
- package/interfaces/external/transformer-package.interface.js +2 -0
- package/interfaces/external/validation-error.interface.d.ts +42 -0
- package/interfaces/external/validation-error.interface.js +2 -0
- package/interfaces/external/validator-options.interface.d.ts +76 -0
- package/interfaces/external/validator-options.interface.js +2 -0
- package/interfaces/external/validator-package.interface.d.ts +5 -0
- package/interfaces/external/validator-package.interface.js +2 -0
- package/interfaces/features/arguments-host.interface.d.ts +88 -0
- package/interfaces/features/arguments-host.interface.js +2 -0
- package/interfaces/features/can-activate.interface.d.ts +22 -0
- package/interfaces/features/can-activate.interface.js +2 -0
- package/interfaces/features/custom-route-param-factory.interface.d.ts +5 -0
- package/interfaces/features/custom-route-param-factory.interface.js +2 -0
- package/interfaces/features/execution-context.interface.d.ts +20 -0
- package/interfaces/features/execution-context.interface.js +2 -0
- package/interfaces/features/nest-interceptor.interface.d.ts +34 -0
- package/interfaces/features/nest-interceptor.interface.js +2 -0
- package/interfaces/features/paramtype.interface.d.ts +4 -0
- package/interfaces/features/paramtype.interface.js +2 -0
- package/interfaces/features/pipe-transform.interface.d.ts +42 -0
- package/interfaces/features/pipe-transform.interface.js +2 -0
- package/interfaces/global-prefix-options.interface.d.ts +7 -0
- package/interfaces/global-prefix-options.interface.js +2 -0
- package/interfaces/hooks/before-application-shutdown.interface.d.ts +3 -0
- package/interfaces/hooks/before-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/index.d.ts +5 -0
- package/interfaces/hooks/index.js +8 -0
- package/interfaces/hooks/on-application-bootstrap.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-bootstrap.interface.js +2 -0
- package/interfaces/hooks/on-application-shutdown.interface.d.ts +11 -0
- package/interfaces/hooks/on-application-shutdown.interface.js +2 -0
- package/interfaces/hooks/on-destroy.interface.d.ts +12 -0
- package/interfaces/hooks/on-destroy.interface.js +2 -0
- package/interfaces/hooks/on-init.interface.d.ts +10 -0
- package/interfaces/hooks/on-init.interface.js +2 -0
- package/interfaces/http/http-exception-body.interface.d.ts +6 -0
- package/interfaces/http/http-exception-body.interface.js +2 -0
- package/interfaces/http/http-redirect-response.interface.d.ts +5 -0
- package/interfaces/http/http-redirect-response.interface.js +2 -0
- package/interfaces/http/http-server.interface.d.ts +70 -0
- package/interfaces/http/http-server.interface.js +2 -0
- package/interfaces/http/index.d.ts +5 -0
- package/interfaces/http/index.js +8 -0
- package/interfaces/http/message-event.interface.d.ts +6 -0
- package/interfaces/http/message-event.interface.js +2 -0
- package/interfaces/http/raw-body-request.interface.d.ts +6 -0
- package/interfaces/http/raw-body-request.interface.js +2 -0
- package/interfaces/index.d.ts +30 -0
- package/interfaces/index.js +33 -0
- package/interfaces/injectable.interface.d.ts +1 -0
- package/interfaces/injectable.interface.js +2 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.d.ts +7 -0
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +2 -0
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +5 -0
- package/interfaces/microservices/nest-microservice-options.interface.js +2 -0
- package/interfaces/middleware/index.d.ts +4 -0
- package/interfaces/middleware/index.js +7 -0
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +24 -0
- package/interfaces/middleware/middleware-config-proxy.interface.js +2 -0
- package/interfaces/middleware/middleware-configuration.interface.d.ts +12 -0
- package/interfaces/middleware/middleware-configuration.interface.js +2 -0
- package/interfaces/middleware/middleware-consumer.interface.d.ts +18 -0
- package/interfaces/middleware/middleware-consumer.interface.js +2 -0
- package/interfaces/middleware/nest-middleware.interface.d.ts +8 -0
- package/interfaces/middleware/nest-middleware.interface.js +2 -0
- package/interfaces/modules/dynamic-module.interface.d.ts +25 -0
- package/interfaces/modules/dynamic-module.interface.js +2 -0
- package/interfaces/modules/forward-reference.interface.d.ts +3 -0
- package/interfaces/modules/forward-reference.interface.js +2 -0
- package/interfaces/modules/index.d.ts +8 -0
- package/interfaces/modules/index.js +11 -0
- package/interfaces/modules/injection-token.interface.d.ts +6 -0
- package/interfaces/modules/injection-token.interface.js +2 -0
- package/interfaces/modules/introspection-result.interface.d.ts +10 -0
- package/interfaces/modules/introspection-result.interface.js +2 -0
- package/interfaces/modules/module-metadata.interface.d.ts +34 -0
- package/interfaces/modules/module-metadata.interface.js +2 -0
- package/interfaces/modules/nest-module.interface.d.ts +7 -0
- package/interfaces/modules/nest-module.interface.js +2 -0
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +8 -0
- package/interfaces/modules/optional-factory-dependency.interface.js +2 -0
- package/interfaces/modules/provider.interface.d.ts +156 -0
- package/interfaces/modules/provider.interface.js +2 -0
- package/interfaces/nest-application-context-options.interface.d.ts +68 -0
- package/interfaces/nest-application-context-options.interface.js +9 -0
- package/interfaces/nest-application-context.interface.d.ts +139 -0
- package/interfaces/nest-application-context.interface.js +2 -0
- package/interfaces/nest-application-options.interface.d.ts +29 -0
- package/interfaces/nest-application-options.interface.js +2 -0
- package/interfaces/nest-application.interface.d.ts +135 -0
- package/interfaces/nest-application.interface.js +2 -0
- package/interfaces/nest-microservice.interface.d.ts +75 -0
- package/interfaces/nest-microservice.interface.js +2 -0
- package/interfaces/scope-options.interface.d.ts +37 -0
- package/interfaces/scope-options.interface.js +23 -0
- package/interfaces/shutdown-hooks-options.interface.d.ts +21 -0
- package/interfaces/shutdown-hooks-options.interface.js +2 -0
- package/interfaces/type.interface.d.ts +3 -0
- package/interfaces/type.interface.js +2 -0
- package/interfaces/version-options.interface.d.ts +92 -0
- package/interfaces/version-options.interface.js +9 -0
- package/interfaces/websockets/web-socket-adapter.interface.d.ts +19 -0
- package/interfaces/websockets/web-socket-adapter.interface.js +2 -0
- package/module-utils/configurable-module.builder.d.ts +93 -0
- package/module-utils/configurable-module.builder.js +219 -0
- package/module-utils/constants.d.ts +9 -0
- package/module-utils/constants.js +19 -0
- package/module-utils/index.d.ts +2 -0
- package/module-utils/index.js +5 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +42 -0
- package/module-utils/interfaces/configurable-module-async-options.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +13 -0
- package/module-utils/interfaces/configurable-module-cls.interface.js +2 -0
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +62 -0
- package/module-utils/interfaces/configurable-module-host.interface.js +2 -0
- package/module-utils/interfaces/index.d.ts +3 -0
- package/module-utils/interfaces/index.js +6 -0
- package/module-utils/utils/generate-options-injection-token.util.d.ts +1 -0
- package/module-utils/utils/generate-options-injection-token.util.js +8 -0
- package/module-utils/utils/get-injection-providers.util.d.ts +8 -0
- package/module-utils/utils/get-injection-providers.util.js +35 -0
- package/module-utils/utils/index.d.ts +2 -0
- package/module-utils/utils/index.js +5 -0
- package/package.json +61 -0
- package/pipes/default-value.pipe.d.ts +13 -0
- package/pipes/default-value.pipe.js +30 -0
- package/pipes/file/file-type.validator.d.ts +62 -0
- package/pipes/file/file-type.validator.js +102 -0
- package/pipes/file/file-validator-context.interface.d.ts +5 -0
- package/pipes/file/file-validator-context.interface.js +2 -0
- package/pipes/file/file-validator.interface.d.ts +21 -0
- package/pipes/file/file-validator.interface.js +15 -0
- package/pipes/file/index.d.ts +6 -0
- package/pipes/file/index.js +9 -0
- package/pipes/file/interfaces/file.interface.d.ts +5 -0
- package/pipes/file/interfaces/file.interface.js +2 -0
- package/pipes/file/interfaces/index.d.ts +1 -0
- package/pipes/file/interfaces/index.js +4 -0
- package/pipes/file/max-file-size.validator.d.ts +44 -0
- package/pipes/file/max-file-size.validator.js +37 -0
- package/pipes/file/parse-file-options.interface.d.ts +15 -0
- package/pipes/file/parse-file-options.interface.js +2 -0
- package/pipes/file/parse-file-pipe.builder.d.ts +15 -0
- package/pipes/file/parse-file-pipe.builder.js +33 -0
- package/pipes/file/parse-file.pipe.d.ts +28 -0
- package/pipes/file/parse-file.pipe.js +76 -0
- package/pipes/index.d.ts +10 -0
- package/pipes/index.js +13 -0
- package/pipes/parse-array.pipe.d.ts +52 -0
- package/pipes/parse-array.pipe.js +148 -0
- package/pipes/parse-bool.pipe.d.ts +55 -0
- package/pipes/parse-bool.pipe.js +67 -0
- package/pipes/parse-date.pipe.d.ts +37 -0
- package/pipes/parse-date.pipe.js +42 -0
- package/pipes/parse-enum.pipe.d.ts +46 -0
- package/pipes/parse-enum.pipe.js +55 -0
- package/pipes/parse-float.pipe.d.ts +49 -0
- package/pipes/parse-float.pipe.js +56 -0
- package/pipes/parse-int.pipe.d.ts +48 -0
- package/pipes/parse-int.pipe.js +57 -0
- package/pipes/parse-uuid.pipe.d.ts +49 -0
- package/pipes/parse-uuid.pipe.js +57 -0
- package/pipes/validation.pipe.d.ts +51 -0
- package/pipes/validation.pipe.js +245 -0
- package/serializer/class-serializer.constants.d.ts +1 -0
- package/serializer/class-serializer.constants.js +4 -0
- package/serializer/class-serializer.interceptor.d.ts +29 -0
- package/serializer/class-serializer.interceptor.js +77 -0
- package/serializer/class-serializer.interfaces.d.ts +8 -0
- package/serializer/class-serializer.interfaces.js +2 -0
- package/serializer/decorators/index.d.ts +1 -0
- package/serializer/decorators/index.js +4 -0
- package/serializer/decorators/serialize-options.decorator.d.ts +5 -0
- package/serializer/decorators/serialize-options.decorator.js +10 -0
- package/serializer/index.d.ts +3 -0
- package/serializer/index.js +6 -0
- package/services/console-logger.service.d.ts +202 -0
- package/services/console-logger.service.js +379 -0
- package/services/index.d.ts +3 -0
- package/services/index.js +6 -0
- package/services/logger.service.d.ts +152 -0
- package/services/logger.service.js +251 -0
- package/services/utils/filter-log-levels.util.d.ts +5 -0
- package/services/utils/filter-log-levels.util.js +23 -0
- package/services/utils/index.d.ts +3 -0
- package/services/utils/index.js +6 -0
- package/services/utils/is-log-level-enabled.util.d.ts +7 -0
- package/services/utils/is-log-level-enabled.util.js +32 -0
- package/services/utils/is-log-level.util.d.ts +5 -0
- package/services/utils/is-log-level.util.js +10 -0
- package/tsconfig.build.json +10 -0
- package/utils/assign-custom-metadata.util.d.ts +4 -0
- package/utils/assign-custom-metadata.util.js +15 -0
- package/utils/cli-colors.util.d.ts +10 -0
- package/utils/cli-colors.util.js +15 -0
- package/utils/extend-metadata.util.d.ts +1 -0
- package/utils/extend-metadata.util.js +8 -0
- package/utils/forward-ref.util.d.ts +5 -0
- package/utils/forward-ref.util.js +10 -0
- package/utils/http-error-by-code.util.d.ts +4 -0
- package/utils/http-error-by-code.util.js +26 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +4 -0
- package/utils/load-package.util.d.ts +1 -0
- package/utils/load-package.util.js +16 -0
- package/utils/merge-with-values.util.d.ts +4 -0
- package/utils/merge-with-values.util.js +18 -0
- package/utils/random-string-generator.util.d.ts +1 -0
- package/utils/random-string-generator.util.js +6 -0
- package/utils/select-exception-filter-metadata.util.d.ts +2 -0
- package/utils/select-exception-filter-metadata.util.js +6 -0
- package/utils/shared.utils.d.ts +13 -0
- package/utils/shared.utils.js +51 -0
- package/utils/validate-each.util.d.ts +8 -0
- package/utils/validate-each.util.js +25 -0
- package/utils/validate-module-keys.util.d.ts +2 -0
- package/utils/validate-module-keys.util.js +22 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Inject = Inject;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Decorator that marks a constructor parameter as a target for
|
|
8
|
+
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
|
|
9
|
+
*
|
|
10
|
+
* Any injected provider must be visible within the module scope (loosely
|
|
11
|
+
* speaking, the containing module) of the class it is being injected into. This
|
|
12
|
+
* can be done by:
|
|
13
|
+
*
|
|
14
|
+
* - defining the provider in the same module scope
|
|
15
|
+
* - exporting the provider from one module scope and importing that module into the
|
|
16
|
+
* module scope of the class being injected into
|
|
17
|
+
* - exporting the provider from a module that is marked as global using the
|
|
18
|
+
* `@Global()` decorator
|
|
19
|
+
*
|
|
20
|
+
* #### Injection tokens
|
|
21
|
+
* Can be *types* (class names), *strings* or *symbols*. This depends on how the
|
|
22
|
+
* provider with which it is associated was defined. Providers defined with the
|
|
23
|
+
* `@Injectable()` decorator use the class name. Custom Providers may use strings
|
|
24
|
+
* or symbols as the injection token.
|
|
25
|
+
*
|
|
26
|
+
* @param token lookup key for the provider to be injected (assigned to the constructor
|
|
27
|
+
* parameter).
|
|
28
|
+
*
|
|
29
|
+
* @see [Providers](https://docs.nestjs.com/providers)
|
|
30
|
+
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
|
|
31
|
+
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
|
32
|
+
*
|
|
33
|
+
* @publicApi
|
|
34
|
+
*/
|
|
35
|
+
function Inject(token) {
|
|
36
|
+
const injectCallHasArguments = arguments.length > 0;
|
|
37
|
+
return (target, key, index) => {
|
|
38
|
+
let type = token || Reflect.getMetadata('design:type', target, key);
|
|
39
|
+
// Try to infer the token in a constructor-based injection
|
|
40
|
+
if (!type && !injectCallHasArguments) {
|
|
41
|
+
type = Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, target, key)?.[index];
|
|
42
|
+
}
|
|
43
|
+
if (!(0, shared_utils_1.isUndefined)(index)) {
|
|
44
|
+
let dependencies = Reflect.getMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, target) || [];
|
|
45
|
+
dependencies = [...dependencies, { index, param: type }];
|
|
46
|
+
Reflect.defineMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, dependencies, target);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let properties = Reflect.getMetadata(constants_1.PROPERTY_DEPS_METADATA, target.constructor) || [];
|
|
50
|
+
properties = [...properties, { key, type }];
|
|
51
|
+
Reflect.defineMetadata(constants_1.PROPERTY_DEPS_METADATA, properties, target.constructor);
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ScopeOptions } from '../../interfaces/scope-options.interface';
|
|
2
|
+
import { Type } from '../../interfaces/type.interface';
|
|
3
|
+
/**
|
|
4
|
+
* Defines the injection scope.
|
|
5
|
+
*
|
|
6
|
+
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
export type InjectableOptions = ScopeOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
13
|
+
* Providers can be injected into other classes via constructor parameter injection
|
|
14
|
+
* using Nest's built-in [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection)
|
|
15
|
+
* system.
|
|
16
|
+
*
|
|
17
|
+
* When injecting a provider, it must be visible within the module scope (loosely
|
|
18
|
+
* speaking, the containing module) of the class it is being injected into. This
|
|
19
|
+
* can be done by:
|
|
20
|
+
*
|
|
21
|
+
* - defining the provider in the same module scope
|
|
22
|
+
* - exporting the provider from one module scope and importing that module into the
|
|
23
|
+
* module scope of the class being injected into
|
|
24
|
+
* - exporting the provider from a module that is marked as global using the
|
|
25
|
+
* `@Global()` decorator
|
|
26
|
+
*
|
|
27
|
+
* Providers can also be defined in a more explicit and imperative form using
|
|
28
|
+
* various [custom provider](https://docs.nestjs.com/fundamentals/custom-providers) techniques that expose
|
|
29
|
+
* more capabilities of the DI system.
|
|
30
|
+
*
|
|
31
|
+
* @param options options specifying scope of injectable
|
|
32
|
+
*
|
|
33
|
+
* @see [Providers](https://docs.nestjs.com/providers)
|
|
34
|
+
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
|
|
35
|
+
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
|
36
|
+
*
|
|
37
|
+
* @publicApi
|
|
38
|
+
*/
|
|
39
|
+
export declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* @publicApi
|
|
42
|
+
*/
|
|
43
|
+
export declare function mixin<T>(mixinClass: Type<T>): Type<T>;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Injectable = Injectable;
|
|
4
|
+
exports.mixin = mixin;
|
|
5
|
+
const uid_1 = require("uid");
|
|
6
|
+
const constants_1 = require("../../constants");
|
|
7
|
+
/**
|
|
8
|
+
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
|
|
9
|
+
* Providers can be injected into other classes via constructor parameter injection
|
|
10
|
+
* using Nest's built-in [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection)
|
|
11
|
+
* system.
|
|
12
|
+
*
|
|
13
|
+
* When injecting a provider, it must be visible within the module scope (loosely
|
|
14
|
+
* speaking, the containing module) of the class it is being injected into. This
|
|
15
|
+
* can be done by:
|
|
16
|
+
*
|
|
17
|
+
* - defining the provider in the same module scope
|
|
18
|
+
* - exporting the provider from one module scope and importing that module into the
|
|
19
|
+
* module scope of the class being injected into
|
|
20
|
+
* - exporting the provider from a module that is marked as global using the
|
|
21
|
+
* `@Global()` decorator
|
|
22
|
+
*
|
|
23
|
+
* Providers can also be defined in a more explicit and imperative form using
|
|
24
|
+
* various [custom provider](https://docs.nestjs.com/fundamentals/custom-providers) techniques that expose
|
|
25
|
+
* more capabilities of the DI system.
|
|
26
|
+
*
|
|
27
|
+
* @param options options specifying scope of injectable
|
|
28
|
+
*
|
|
29
|
+
* @see [Providers](https://docs.nestjs.com/providers)
|
|
30
|
+
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
|
|
31
|
+
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
|
|
32
|
+
*
|
|
33
|
+
* @publicApi
|
|
34
|
+
*/
|
|
35
|
+
function Injectable(options) {
|
|
36
|
+
return (target) => {
|
|
37
|
+
Reflect.defineMetadata(constants_1.INJECTABLE_WATERMARK, true, target);
|
|
38
|
+
Reflect.defineMetadata(constants_1.SCOPE_OPTIONS_METADATA, options, target);
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @publicApi
|
|
43
|
+
*/
|
|
44
|
+
function mixin(mixinClass) {
|
|
45
|
+
Object.defineProperty(mixinClass, 'name', {
|
|
46
|
+
value: (0, uid_1.uid)(21),
|
|
47
|
+
});
|
|
48
|
+
Injectable()(mixinClass);
|
|
49
|
+
return mixinClass;
|
|
50
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parameter decorator for an injected dependency marking the
|
|
3
|
+
* dependency as optional.
|
|
4
|
+
*
|
|
5
|
+
* For example:
|
|
6
|
+
* ```typescript
|
|
7
|
+
* constructor(@Optional() @Inject('HTTP_OPTIONS')private readonly httpClient: T) {}
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @see [Optional providers](https://docs.nestjs.com/providers#optional-providers)
|
|
11
|
+
*
|
|
12
|
+
* @publicApi
|
|
13
|
+
*/
|
|
14
|
+
export declare function Optional(): PropertyDecorator & ParameterDecorator;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Optional = Optional;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
6
|
+
/**
|
|
7
|
+
* Parameter decorator for an injected dependency marking the
|
|
8
|
+
* dependency as optional.
|
|
9
|
+
*
|
|
10
|
+
* For example:
|
|
11
|
+
* ```typescript
|
|
12
|
+
* constructor(@Optional() @Inject('HTTP_OPTIONS')private readonly httpClient: T) {}
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @see [Optional providers](https://docs.nestjs.com/providers#optional-providers)
|
|
16
|
+
*
|
|
17
|
+
* @publicApi
|
|
18
|
+
*/
|
|
19
|
+
function Optional() {
|
|
20
|
+
return (target, key, index) => {
|
|
21
|
+
if (!(0, shared_utils_1.isUndefined)(index)) {
|
|
22
|
+
const args = Reflect.getMetadata(constants_1.OPTIONAL_DEPS_METADATA, target) || [];
|
|
23
|
+
Reflect.defineMetadata(constants_1.OPTIONAL_DEPS_METADATA, [...args, index], target);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
const properties = Reflect.getMetadata(constants_1.OPTIONAL_PROPERTY_DEPS_METADATA, target.constructor) || [];
|
|
27
|
+
Reflect.defineMetadata(constants_1.OPTIONAL_PROPERTY_DEPS_METADATA, [...properties, key], target.constructor);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type CustomDecorator<TKey = string> = MethodDecorator & ClassDecorator & {
|
|
2
|
+
KEY: TKey;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Decorator that assigns metadata to the class/function using the
|
|
6
|
+
* specified `key`.
|
|
7
|
+
*
|
|
8
|
+
* Requires two parameters:
|
|
9
|
+
* - `key` - a value defining the key under which the metadata is stored
|
|
10
|
+
* - `value` - metadata to be associated with `key`
|
|
11
|
+
*
|
|
12
|
+
* This metadata can be reflected using the `Reflector` class.
|
|
13
|
+
*
|
|
14
|
+
* Example: `@SetMetadata('roles', ['admin'])`
|
|
15
|
+
*
|
|
16
|
+
* @see [Reflection](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata)
|
|
17
|
+
*
|
|
18
|
+
* @publicApi
|
|
19
|
+
*/
|
|
20
|
+
export declare const SetMetadata: <K = string, V = any>(metadataKey: K, metadataValue: V) => CustomDecorator<K>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SetMetadata = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Decorator that assigns metadata to the class/function using the
|
|
6
|
+
* specified `key`.
|
|
7
|
+
*
|
|
8
|
+
* Requires two parameters:
|
|
9
|
+
* - `key` - a value defining the key under which the metadata is stored
|
|
10
|
+
* - `value` - metadata to be associated with `key`
|
|
11
|
+
*
|
|
12
|
+
* This metadata can be reflected using the `Reflector` class.
|
|
13
|
+
*
|
|
14
|
+
* Example: `@SetMetadata('roles', ['admin'])`
|
|
15
|
+
*
|
|
16
|
+
* @see [Reflection](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata)
|
|
17
|
+
*
|
|
18
|
+
* @publicApi
|
|
19
|
+
*/
|
|
20
|
+
const SetMetadata = (metadataKey, metadataValue) => {
|
|
21
|
+
const decoratorFactory = (target, key, descriptor) => {
|
|
22
|
+
if (descriptor) {
|
|
23
|
+
Reflect.defineMetadata(metadataKey, metadataValue, descriptor.value);
|
|
24
|
+
return descriptor;
|
|
25
|
+
}
|
|
26
|
+
Reflect.defineMetadata(metadataKey, metadataValue, target);
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
decoratorFactory.KEY = metadataKey;
|
|
30
|
+
return decoratorFactory;
|
|
31
|
+
};
|
|
32
|
+
exports.SetMetadata = SetMetadata;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CanActivate } from '../../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that binds guards to the scope of the controller or method,
|
|
4
|
+
* depending on its context.
|
|
5
|
+
*
|
|
6
|
+
* When `@UseGuards` is used at the controller level, the guard will be
|
|
7
|
+
* applied to every handler (method) in the controller.
|
|
8
|
+
*
|
|
9
|
+
* When `@UseGuards` is used at the individual handler level, the guard
|
|
10
|
+
* will apply only to that specific method.
|
|
11
|
+
*
|
|
12
|
+
* @param guards a single guard instance or class, or a list of guard instances
|
|
13
|
+
* or classes.
|
|
14
|
+
*
|
|
15
|
+
* @see [Guards](https://docs.nestjs.com/guards)
|
|
16
|
+
*
|
|
17
|
+
* @usageNotes
|
|
18
|
+
* Guards can also be set up globally for all controllers and routes
|
|
19
|
+
* using `app.useGlobalGuards()`. [See here for details](https://docs.nestjs.com/guards#binding-guards)
|
|
20
|
+
*
|
|
21
|
+
* @publicApi
|
|
22
|
+
*/
|
|
23
|
+
export declare function UseGuards(...guards: (CanActivate | Function)[]): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseGuards = UseGuards;
|
|
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
|
+
* Decorator that binds guards to the scope of the controller or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UseGuards` is used at the controller level, the guard will be
|
|
13
|
+
* applied to every handler (method) in the controller.
|
|
14
|
+
*
|
|
15
|
+
* When `@UseGuards` is used at the individual handler level, the guard
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param guards a single guard instance or class, or a list of guard instances
|
|
19
|
+
* or classes.
|
|
20
|
+
*
|
|
21
|
+
* @see [Guards](https://docs.nestjs.com/guards)
|
|
22
|
+
*
|
|
23
|
+
* @usageNotes
|
|
24
|
+
* Guards can also be set up globally for all controllers and routes
|
|
25
|
+
* using `app.useGlobalGuards()`. [See here for details](https://docs.nestjs.com/guards#binding-guards)
|
|
26
|
+
*
|
|
27
|
+
* @publicApi
|
|
28
|
+
*/
|
|
29
|
+
function UseGuards(...guards) {
|
|
30
|
+
return (target, key, descriptor) => {
|
|
31
|
+
const isGuardValid = (guard) => guard && ((0, shared_utils_1.isFunction)(guard) || (0, shared_utils_1.isFunction)(guard.canActivate));
|
|
32
|
+
if (descriptor) {
|
|
33
|
+
(0, validate_each_util_1.validateEach)(target.constructor, guards, isGuardValid, '@UseGuards', 'guard');
|
|
34
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, descriptor.value);
|
|
35
|
+
return descriptor;
|
|
36
|
+
}
|
|
37
|
+
(0, validate_each_util_1.validateEach)(target, guards, isGuardValid, '@UseGuards', 'guard');
|
|
38
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, target);
|
|
39
|
+
return target;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NestInterceptor } from '../../interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that binds interceptors to the scope of the controller or method,
|
|
4
|
+
* depending on its context.
|
|
5
|
+
*
|
|
6
|
+
* When `@UseInterceptors` is used at the controller level, the interceptor will
|
|
7
|
+
* be applied to every handler (method) in the controller.
|
|
8
|
+
*
|
|
9
|
+
* When `@UseInterceptors` is used at the individual handler level, the interceptor
|
|
10
|
+
* will apply only to that specific method.
|
|
11
|
+
*
|
|
12
|
+
* @param interceptors a single interceptor instance or class, or a list of
|
|
13
|
+
* interceptor instances or classes.
|
|
14
|
+
*
|
|
15
|
+
* @see [Interceptors](https://docs.nestjs.com/interceptors)
|
|
16
|
+
*
|
|
17
|
+
* @usageNotes
|
|
18
|
+
* Interceptors can also be set up globally for all controllers and routes
|
|
19
|
+
* using `app.useGlobalInterceptors()`. [See here for details](https://docs.nestjs.com/interceptors#binding-interceptors)
|
|
20
|
+
*
|
|
21
|
+
* @publicApi
|
|
22
|
+
*/
|
|
23
|
+
export declare function UseInterceptors(...interceptors: (NestInterceptor | Function)[]): MethodDecorator & ClassDecorator;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UseInterceptors = UseInterceptors;
|
|
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
|
+
* Decorator that binds interceptors to the scope of the controller or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UseInterceptors` is used at the controller level, the interceptor will
|
|
13
|
+
* be applied to every handler (method) in the controller.
|
|
14
|
+
*
|
|
15
|
+
* When `@UseInterceptors` is used at the individual handler level, the interceptor
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param interceptors a single interceptor instance or class, or a list of
|
|
19
|
+
* interceptor instances or classes.
|
|
20
|
+
*
|
|
21
|
+
* @see [Interceptors](https://docs.nestjs.com/interceptors)
|
|
22
|
+
*
|
|
23
|
+
* @usageNotes
|
|
24
|
+
* Interceptors can also be set up globally for all controllers and routes
|
|
25
|
+
* using `app.useGlobalInterceptors()`. [See here for details](https://docs.nestjs.com/interceptors#binding-interceptors)
|
|
26
|
+
*
|
|
27
|
+
* @publicApi
|
|
28
|
+
*/
|
|
29
|
+
function UseInterceptors(...interceptors) {
|
|
30
|
+
return (target, key, descriptor) => {
|
|
31
|
+
const isInterceptorValid = (interceptor) => interceptor &&
|
|
32
|
+
((0, shared_utils_1.isFunction)(interceptor) || (0, shared_utils_1.isFunction)(interceptor.intercept));
|
|
33
|
+
if (descriptor) {
|
|
34
|
+
(0, validate_each_util_1.validateEach)(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
35
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
|
|
36
|
+
return descriptor;
|
|
37
|
+
}
|
|
38
|
+
(0, validate_each_util_1.validateEach)(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
|
|
39
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, target);
|
|
40
|
+
return target;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PipeTransform } from '../../interfaces/index';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator that binds pipes to the scope of the controller or method,
|
|
4
|
+
* depending on its context.
|
|
5
|
+
*
|
|
6
|
+
* When `@UsePipes` is used at the controller level, the pipe will be
|
|
7
|
+
* applied to every handler (method) in the controller.
|
|
8
|
+
*
|
|
9
|
+
* When `@UsePipes` is used at the individual handler level, the pipe
|
|
10
|
+
* will apply only to that specific method.
|
|
11
|
+
*
|
|
12
|
+
* @param pipes a single pipe instance or class, or a list of pipe instances or
|
|
13
|
+
* classes.
|
|
14
|
+
*
|
|
15
|
+
* @see [Pipes](https://docs.nestjs.com/pipes)
|
|
16
|
+
*
|
|
17
|
+
* @usageNotes
|
|
18
|
+
* Pipes can also be set up globally for all controllers and routes
|
|
19
|
+
* using `app.useGlobalPipes()`. [See here for details](https://docs.nestjs.com/pipes#class-validator)
|
|
20
|
+
*
|
|
21
|
+
* @publicApi
|
|
22
|
+
*/
|
|
23
|
+
export declare function UsePipes(...pipes: (PipeTransform | Function)[]): ClassDecorator & MethodDecorator;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsePipes = UsePipes;
|
|
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
|
+
* Decorator that binds pipes to the scope of the controller or method,
|
|
10
|
+
* depending on its context.
|
|
11
|
+
*
|
|
12
|
+
* When `@UsePipes` is used at the controller level, the pipe will be
|
|
13
|
+
* applied to every handler (method) in the controller.
|
|
14
|
+
*
|
|
15
|
+
* When `@UsePipes` is used at the individual handler level, the pipe
|
|
16
|
+
* will apply only to that specific method.
|
|
17
|
+
*
|
|
18
|
+
* @param pipes a single pipe instance or class, or a list of pipe instances or
|
|
19
|
+
* classes.
|
|
20
|
+
*
|
|
21
|
+
* @see [Pipes](https://docs.nestjs.com/pipes)
|
|
22
|
+
*
|
|
23
|
+
* @usageNotes
|
|
24
|
+
* Pipes can also be set up globally for all controllers and routes
|
|
25
|
+
* using `app.useGlobalPipes()`. [See here for details](https://docs.nestjs.com/pipes#class-validator)
|
|
26
|
+
*
|
|
27
|
+
* @publicApi
|
|
28
|
+
*/
|
|
29
|
+
function UsePipes(...pipes) {
|
|
30
|
+
return (target, key, descriptor) => {
|
|
31
|
+
const isPipeValid = (pipe) => pipe && ((0, shared_utils_1.isFunction)(pipe) || (0, shared_utils_1.isFunction)(pipe.transform));
|
|
32
|
+
if (descriptor) {
|
|
33
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, descriptor.value);
|
|
34
|
+
return descriptor;
|
|
35
|
+
}
|
|
36
|
+
(0, validate_each_util_1.validateEach)(target, pipes, isPipeValid, '@UsePipes', 'pipe');
|
|
37
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, target);
|
|
38
|
+
return target;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Version = Version;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Sets the version of the endpoint to the passed version
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
function Version(version) {
|
|
11
|
+
if (Array.isArray(version)) {
|
|
12
|
+
// Drop duplicated versions
|
|
13
|
+
version = Array.from(new Set(version));
|
|
14
|
+
}
|
|
15
|
+
return (target, key, descriptor) => {
|
|
16
|
+
Reflect.defineMetadata(constants_1.VERSION_METADATA, version, descriptor.value);
|
|
17
|
+
return descriptor;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { PipeTransform } from '../../index';
|
|
2
|
+
import { Type } from '../../interfaces';
|
|
3
|
+
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
|
|
4
|
+
export type ParamDecoratorEnhancer = ParameterDecorator;
|
|
5
|
+
/**
|
|
6
|
+
* Defines HTTP route param decorator
|
|
7
|
+
*
|
|
8
|
+
* @param factory
|
|
9
|
+
* @param enhancers
|
|
10
|
+
*
|
|
11
|
+
* @publicApi
|
|
12
|
+
*/
|
|
13
|
+
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createParamDecorator = createParamDecorator;
|
|
4
|
+
const uid_1 = require("uid");
|
|
5
|
+
const constants_1 = require("../../constants");
|
|
6
|
+
const assign_custom_metadata_util_1 = require("../../utils/assign-custom-metadata.util");
|
|
7
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
8
|
+
/**
|
|
9
|
+
* Defines HTTP route param decorator
|
|
10
|
+
*
|
|
11
|
+
* @param factory
|
|
12
|
+
* @param enhancers
|
|
13
|
+
*
|
|
14
|
+
* @publicApi
|
|
15
|
+
*/
|
|
16
|
+
function createParamDecorator(factory, enhancers = []) {
|
|
17
|
+
const paramtype = (0, uid_1.uid)(21);
|
|
18
|
+
return (data, ...pipes) => (target, key, index) => {
|
|
19
|
+
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) ||
|
|
20
|
+
{};
|
|
21
|
+
const isPipe = (pipe) => pipe &&
|
|
22
|
+
(((0, shared_utils_1.isFunction)(pipe) &&
|
|
23
|
+
pipe.prototype &&
|
|
24
|
+
(0, shared_utils_1.isFunction)(pipe.prototype.transform)) ||
|
|
25
|
+
(0, shared_utils_1.isFunction)(pipe.transform));
|
|
26
|
+
const hasParamData = (0, shared_utils_1.isNil)(data) || !isPipe(data);
|
|
27
|
+
const paramData = hasParamData ? data : undefined;
|
|
28
|
+
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
29
|
+
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, (0, assign_custom_metadata_util_1.assignCustomParameterMetadata)(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
|
|
30
|
+
enhancers.forEach(fn => fn(target, key, index));
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request method Decorator. Sets a response header.
|
|
3
|
+
*
|
|
4
|
+
* For example:
|
|
5
|
+
* `@Header('Cache-Control', 'none')`
|
|
6
|
+
* `@Header('Cache-Control', () => 'none')`
|
|
7
|
+
*
|
|
8
|
+
* @param name string to be used for header name
|
|
9
|
+
* @param value string to be used for header value
|
|
10
|
+
*
|
|
11
|
+
* @see [Headers](https://docs.nestjs.com/controllers#headers)
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
14
|
+
*/
|
|
15
|
+
export declare function Header(name: string, value: string | (() => string)): MethodDecorator;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Header = Header;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
6
|
+
/**
|
|
7
|
+
* Request method Decorator. Sets a response header.
|
|
8
|
+
*
|
|
9
|
+
* For example:
|
|
10
|
+
* `@Header('Cache-Control', 'none')`
|
|
11
|
+
* `@Header('Cache-Control', () => 'none')`
|
|
12
|
+
*
|
|
13
|
+
* @param name string to be used for header name
|
|
14
|
+
* @param value string to be used for header value
|
|
15
|
+
*
|
|
16
|
+
* @see [Headers](https://docs.nestjs.com/controllers#headers)
|
|
17
|
+
*
|
|
18
|
+
* @publicApi
|
|
19
|
+
*/
|
|
20
|
+
function Header(name, value) {
|
|
21
|
+
return (target, key, descriptor) => {
|
|
22
|
+
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
23
|
+
return descriptor;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
3
|
+
* default status code for the decorated request method.
|
|
4
|
+
*
|
|
5
|
+
* @param statusCode HTTP response code to be returned by route handler.
|
|
6
|
+
*
|
|
7
|
+
* @see [Http Status Codes](https://docs.nestjs.com/controllers#status-code)
|
|
8
|
+
*
|
|
9
|
+
* @publicApi
|
|
10
|
+
*/
|
|
11
|
+
export declare function HttpCode(statusCode: number): MethodDecorator;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpCode = HttpCode;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
7
|
+
* default status code for the decorated request method.
|
|
8
|
+
*
|
|
9
|
+
* @param statusCode HTTP response code to be returned by route handler.
|
|
10
|
+
*
|
|
11
|
+
* @see [Http Status Codes](https://docs.nestjs.com/controllers#status-code)
|
|
12
|
+
*
|
|
13
|
+
* @publicApi
|
|
14
|
+
*/
|
|
15
|
+
function HttpCode(statusCode) {
|
|
16
|
+
return (target, key, descriptor) => {
|
|
17
|
+
Reflect.defineMetadata(constants_1.HTTP_CODE_METADATA, statusCode, descriptor.value);
|
|
18
|
+
return descriptor;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './request-mapping.decorator';
|
|
2
|
+
export * from './route-params.decorator';
|
|
3
|
+
export * from './http-code.decorator';
|
|
4
|
+
export * from './create-route-param-metadata.decorator';
|
|
5
|
+
export * from './render.decorator';
|
|
6
|
+
export * from './header.decorator';
|
|
7
|
+
export * from './redirect.decorator';
|
|
8
|
+
export * from './sse.decorator';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./request-mapping.decorator"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./route-params.decorator"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./http-code.decorator"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./create-route-param-metadata.decorator"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./render.decorator"), exports);
|
|
9
|
+
tslib_1.__exportStar(require("./header.decorator"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./redirect.decorator"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./sse.decorator"), exports);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Redirect = Redirect;
|
|
4
|
+
const constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
* Redirects request to the specified URL.
|
|
7
|
+
*
|
|
8
|
+
* @publicApi
|
|
9
|
+
*/
|
|
10
|
+
function Redirect(url = '', statusCode) {
|
|
11
|
+
return (target, key, descriptor) => {
|
|
12
|
+
Reflect.defineMetadata(constants_1.REDIRECT_METADATA, { statusCode, url }, descriptor.value);
|
|
13
|
+
return descriptor;
|
|
14
|
+
};
|
|
15
|
+
}
|