@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,445 @@
|
|
|
1
|
+
import { PipeTransform } from '../../index';
|
|
2
|
+
import { Type } from '../../interfaces';
|
|
3
|
+
/**
|
|
4
|
+
* The `@Response()`/`@Res` parameter decorator options.
|
|
5
|
+
*/
|
|
6
|
+
export interface ResponseDecoratorOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Determines whether the response will be sent manually within the route handler,
|
|
9
|
+
* with the use of native response handling methods exposed by the platform-specific response object,
|
|
10
|
+
* or if it should passthrough Nest response processing pipeline.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
passthrough: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type ParamData = object | string | number;
|
|
17
|
+
export interface RouteParamMetadata {
|
|
18
|
+
index: number;
|
|
19
|
+
data?: ParamData;
|
|
20
|
+
}
|
|
21
|
+
export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number, data?: ParamData, ...pipes: (Type<PipeTransform> | PipeTransform)[]): TArgs & {
|
|
22
|
+
[x: string]: {
|
|
23
|
+
index: number;
|
|
24
|
+
data: ParamData | undefined;
|
|
25
|
+
pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Route handler parameter decorator. Extracts the `Request`
|
|
30
|
+
* object from the underlying platform and populates the decorated
|
|
31
|
+
* parameter with the value of `Request`.
|
|
32
|
+
*
|
|
33
|
+
* Example: `logout(@Request() req)`
|
|
34
|
+
*
|
|
35
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
36
|
+
*
|
|
37
|
+
* @publicApi
|
|
38
|
+
*/
|
|
39
|
+
export declare const Request: () => ParameterDecorator;
|
|
40
|
+
/**
|
|
41
|
+
* Route handler parameter decorator. Extracts the `Response`
|
|
42
|
+
* object from the underlying platform and populates the decorated
|
|
43
|
+
* parameter with the value of `Response`.
|
|
44
|
+
*
|
|
45
|
+
* Example: `logout(@Response() res)`
|
|
46
|
+
*
|
|
47
|
+
* @publicApi
|
|
48
|
+
*/
|
|
49
|
+
export declare const Response: (options?: ResponseDecoratorOptions) => ParameterDecorator;
|
|
50
|
+
/**
|
|
51
|
+
* Route handler parameter decorator. Extracts reference to the `Next` function
|
|
52
|
+
* from the underlying platform and populates the decorated
|
|
53
|
+
* parameter with the value of `Next`.
|
|
54
|
+
*
|
|
55
|
+
* @publicApi
|
|
56
|
+
*/
|
|
57
|
+
export declare const Next: () => ParameterDecorator;
|
|
58
|
+
/**
|
|
59
|
+
* Route handler parameter decorator. Extracts the `Ip` property
|
|
60
|
+
* from the `req` object and populates the decorated
|
|
61
|
+
* parameter with the value of `ip`.
|
|
62
|
+
*
|
|
63
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
64
|
+
*
|
|
65
|
+
* @publicApi
|
|
66
|
+
*/
|
|
67
|
+
export declare const Ip: () => ParameterDecorator;
|
|
68
|
+
/**
|
|
69
|
+
* Route handler parameter decorator. Extracts the `Session` object
|
|
70
|
+
* from the underlying platform and populates the decorated
|
|
71
|
+
* parameter with the value of `Session`.
|
|
72
|
+
*
|
|
73
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
74
|
+
*
|
|
75
|
+
* @publicApi
|
|
76
|
+
*/
|
|
77
|
+
export declare const Session: () => ParameterDecorator;
|
|
78
|
+
/**
|
|
79
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
80
|
+
* and populates the decorated parameter with the value of `file`.
|
|
81
|
+
* Used in conjunction with
|
|
82
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
83
|
+
*
|
|
84
|
+
* For example:
|
|
85
|
+
* ```typescript
|
|
86
|
+
* uploadFile(@UploadedFile() file) {
|
|
87
|
+
* console.log(file);
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
91
|
+
*
|
|
92
|
+
* @publicApi
|
|
93
|
+
*/
|
|
94
|
+
export declare function UploadedFile(): ParameterDecorator;
|
|
95
|
+
/**
|
|
96
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
97
|
+
* and populates the decorated parameter with the value of `file`.
|
|
98
|
+
* Used in conjunction with
|
|
99
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
100
|
+
*
|
|
101
|
+
* For example:
|
|
102
|
+
* ```typescript
|
|
103
|
+
* uploadFile(@UploadedFile() file) {
|
|
104
|
+
* console.log(file);
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
108
|
+
*
|
|
109
|
+
* @publicApi
|
|
110
|
+
*/
|
|
111
|
+
export declare function UploadedFile(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
112
|
+
/**
|
|
113
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
114
|
+
* and populates the decorated parameter with the value of `file`.
|
|
115
|
+
* Used in conjunction with
|
|
116
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
117
|
+
*
|
|
118
|
+
* For example:
|
|
119
|
+
* ```typescript
|
|
120
|
+
* uploadFile(@UploadedFile() file) {
|
|
121
|
+
* console.log(file);
|
|
122
|
+
* }
|
|
123
|
+
* ```
|
|
124
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
125
|
+
*
|
|
126
|
+
* @publicApi
|
|
127
|
+
*/
|
|
128
|
+
export declare function UploadedFile(fileKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
129
|
+
/**
|
|
130
|
+
* Route handler parameter decorator. Extracts the `files` object
|
|
131
|
+
* and populates the decorated parameter with the value of `files`.
|
|
132
|
+
* Used in conjunction with
|
|
133
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
134
|
+
*
|
|
135
|
+
* For example:
|
|
136
|
+
* ```typescript
|
|
137
|
+
* uploadFile(@UploadedFiles() files) {
|
|
138
|
+
* console.log(files);
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
141
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
142
|
+
*
|
|
143
|
+
* @publicApi
|
|
144
|
+
*/
|
|
145
|
+
export declare function UploadedFiles(): ParameterDecorator;
|
|
146
|
+
/**
|
|
147
|
+
* Route handler parameter decorator. Extracts the `files` object
|
|
148
|
+
* and populates the decorated parameter with the value of `files`.
|
|
149
|
+
* Used in conjunction with
|
|
150
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
151
|
+
*
|
|
152
|
+
* For example:
|
|
153
|
+
* ```typescript
|
|
154
|
+
* uploadFile(@UploadedFiles() files) {
|
|
155
|
+
* console.log(files);
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
159
|
+
*
|
|
160
|
+
* @publicApi
|
|
161
|
+
*/
|
|
162
|
+
export declare function UploadedFiles(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
163
|
+
/**
|
|
164
|
+
* Route handler parameter decorator. Extracts the `headers`
|
|
165
|
+
* property from the `req` object and populates the decorated
|
|
166
|
+
* parameter with the value of `headers`.
|
|
167
|
+
*
|
|
168
|
+
* For example: `async update(@Headers('Cache-Control') cacheControl: string)`
|
|
169
|
+
*
|
|
170
|
+
* @param property name of single header property to extract.
|
|
171
|
+
*
|
|
172
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
173
|
+
*
|
|
174
|
+
* @publicApi
|
|
175
|
+
*/
|
|
176
|
+
export declare const Headers: (property?: string) => ParameterDecorator;
|
|
177
|
+
/**
|
|
178
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
179
|
+
* property from the `req` object and populates the decorated
|
|
180
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
181
|
+
* query parameter.
|
|
182
|
+
*
|
|
183
|
+
* For example:
|
|
184
|
+
* ```typescript
|
|
185
|
+
* async find(@Query('user') user: string)
|
|
186
|
+
* ```
|
|
187
|
+
*
|
|
188
|
+
* @param property name of single property to extract from the `query` object
|
|
189
|
+
* @param pipes one or more pipes to apply to the bound query parameter
|
|
190
|
+
*
|
|
191
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
192
|
+
*
|
|
193
|
+
* @publicApi
|
|
194
|
+
*/
|
|
195
|
+
export declare function Query(): ParameterDecorator;
|
|
196
|
+
/**
|
|
197
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
198
|
+
* property from the `req` object and populates the decorated
|
|
199
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
200
|
+
* query parameter.
|
|
201
|
+
*
|
|
202
|
+
* For example:
|
|
203
|
+
* ```typescript
|
|
204
|
+
* async find(@Query('user') user: string)
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @param property name of single property to extract from the `query` object
|
|
208
|
+
* @param pipes one or more pipes to apply to the bound query parameter
|
|
209
|
+
*
|
|
210
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
211
|
+
*
|
|
212
|
+
* @publicApi
|
|
213
|
+
*/
|
|
214
|
+
export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
215
|
+
/**
|
|
216
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
217
|
+
* property from the `req` object and populates the decorated
|
|
218
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
219
|
+
* query parameter.
|
|
220
|
+
*
|
|
221
|
+
* For example:
|
|
222
|
+
* ```typescript
|
|
223
|
+
* async find(@Query('user') user: string)
|
|
224
|
+
* ```
|
|
225
|
+
*
|
|
226
|
+
* @param property name of single property to extract from the `query` object
|
|
227
|
+
* @param pipes one or more pipes to apply to the bound query parameter
|
|
228
|
+
*
|
|
229
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
230
|
+
*
|
|
231
|
+
* @publicApi
|
|
232
|
+
*/
|
|
233
|
+
export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
234
|
+
/**
|
|
235
|
+
* Route handler parameter decorator. Extracts the entire `body`
|
|
236
|
+
* object from the `req` object and populates the decorated
|
|
237
|
+
* parameter with the value of `body`.
|
|
238
|
+
*
|
|
239
|
+
* For example:
|
|
240
|
+
* ```typescript
|
|
241
|
+
* async create(@Body() createDto: CreateCatDto)
|
|
242
|
+
* ```
|
|
243
|
+
*
|
|
244
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
245
|
+
*
|
|
246
|
+
* @publicApi
|
|
247
|
+
*/
|
|
248
|
+
export declare function Body(): ParameterDecorator;
|
|
249
|
+
/**
|
|
250
|
+
* Route handler parameter decorator. Extracts the entire `body`
|
|
251
|
+
* object from the `req` object and populates the decorated
|
|
252
|
+
* parameter with the value of `body`. Also applies the specified
|
|
253
|
+
* pipes to that parameter.
|
|
254
|
+
*
|
|
255
|
+
* For example:
|
|
256
|
+
* ```typescript
|
|
257
|
+
* async create(@Body(new ValidationPipe()) createDto: CreateCatDto)
|
|
258
|
+
* ```
|
|
259
|
+
*
|
|
260
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
261
|
+
* the bound body parameter.
|
|
262
|
+
*
|
|
263
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
264
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
265
|
+
*
|
|
266
|
+
* @publicApi
|
|
267
|
+
*/
|
|
268
|
+
export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
269
|
+
/**
|
|
270
|
+
* Route handler parameter decorator. Extracts a single property from
|
|
271
|
+
* the `body` object property of the `req` object and populates the decorated
|
|
272
|
+
* parameter with the value of that property. Also applies pipes to the bound
|
|
273
|
+
* body parameter.
|
|
274
|
+
*
|
|
275
|
+
* For example:
|
|
276
|
+
* ```typescript
|
|
277
|
+
* async create(@Body('role', new ValidationPipe()) role: string)
|
|
278
|
+
* ```
|
|
279
|
+
*
|
|
280
|
+
* @param property name of single property to extract from the `body` object
|
|
281
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
282
|
+
* the bound body parameter.
|
|
283
|
+
*
|
|
284
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
285
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
286
|
+
*
|
|
287
|
+
* @publicApi
|
|
288
|
+
*/
|
|
289
|
+
export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
290
|
+
/**
|
|
291
|
+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
|
|
292
|
+
* property from the `req` object and populates the decorated parameter with that value.
|
|
293
|
+
*
|
|
294
|
+
* For example:
|
|
295
|
+
* ```typescript
|
|
296
|
+
* async create(@RawBody() rawBody: Buffer | undefined)
|
|
297
|
+
* ```
|
|
298
|
+
*
|
|
299
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
300
|
+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
|
|
301
|
+
*
|
|
302
|
+
* @publicApi
|
|
303
|
+
*/
|
|
304
|
+
export declare function RawBody(): ParameterDecorator;
|
|
305
|
+
/**
|
|
306
|
+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
|
|
307
|
+
* property from the `req` object and populates the decorated parameter with that value.
|
|
308
|
+
* Also applies pipes to the bound rawBody parameter.
|
|
309
|
+
*
|
|
310
|
+
* For example:
|
|
311
|
+
* ```typescript
|
|
312
|
+
* async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
|
|
313
|
+
* ```
|
|
314
|
+
*
|
|
315
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
316
|
+
* the bound body parameter.
|
|
317
|
+
*
|
|
318
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
319
|
+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
|
|
320
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
321
|
+
*
|
|
322
|
+
* @publicApi
|
|
323
|
+
*/
|
|
324
|
+
export declare function RawBody(...pipes: (Type<PipeTransform<Buffer | undefined>> | PipeTransform<Buffer | undefined>)[]): ParameterDecorator;
|
|
325
|
+
/**
|
|
326
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
327
|
+
* property from the `req` object and populates the decorated
|
|
328
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
329
|
+
* parameter.
|
|
330
|
+
*
|
|
331
|
+
* For example, extracting all params:
|
|
332
|
+
* ```typescript
|
|
333
|
+
* findOne(@Param() params: string[])
|
|
334
|
+
* ```
|
|
335
|
+
*
|
|
336
|
+
* For example, extracting a single param:
|
|
337
|
+
* ```typescript
|
|
338
|
+
* findOne(@Param('id') id: string)
|
|
339
|
+
* ```
|
|
340
|
+
* @param property name of single property to extract from the `req` object
|
|
341
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
342
|
+
* the bound parameter.
|
|
343
|
+
*
|
|
344
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
345
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
346
|
+
*
|
|
347
|
+
* @publicApi
|
|
348
|
+
*/
|
|
349
|
+
export declare function Param(): ParameterDecorator;
|
|
350
|
+
/**
|
|
351
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
352
|
+
* property from the `req` object and populates the decorated
|
|
353
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
354
|
+
* parameter.
|
|
355
|
+
*
|
|
356
|
+
* For example, extracting all params:
|
|
357
|
+
* ```typescript
|
|
358
|
+
* findOne(@Param() params: string[])
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* For example, extracting a single param:
|
|
362
|
+
* ```typescript
|
|
363
|
+
* findOne(@Param('id') id: string)
|
|
364
|
+
* ```
|
|
365
|
+
* @param property name of single property to extract from the `req` object
|
|
366
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
367
|
+
* the bound parameter.
|
|
368
|
+
*
|
|
369
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
370
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
371
|
+
*
|
|
372
|
+
* @publicApi
|
|
373
|
+
*/
|
|
374
|
+
export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
375
|
+
/**
|
|
376
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
377
|
+
* property from the `req` object and populates the decorated
|
|
378
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
379
|
+
* parameter.
|
|
380
|
+
*
|
|
381
|
+
* For example, extracting all params:
|
|
382
|
+
* ```typescript
|
|
383
|
+
* findOne(@Param() params: string[])
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* For example, extracting a single param:
|
|
387
|
+
* ```typescript
|
|
388
|
+
* findOne(@Param('id') id: string)
|
|
389
|
+
* ```
|
|
390
|
+
* @param property name of single property to extract from the `req` object
|
|
391
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
392
|
+
* the bound parameter.
|
|
393
|
+
*
|
|
394
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
395
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
396
|
+
*
|
|
397
|
+
* @publicApi
|
|
398
|
+
*/
|
|
399
|
+
export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
400
|
+
/**
|
|
401
|
+
* Route handler parameter decorator. Extracts the `hosts`
|
|
402
|
+
* property from the `req` object and populates the decorated
|
|
403
|
+
* parameter with the value of `hosts`. May also apply pipes to the bound
|
|
404
|
+
* parameter.
|
|
405
|
+
*
|
|
406
|
+
* For example, extracting all params:
|
|
407
|
+
* ```typescript
|
|
408
|
+
* findOne(@HostParam() params: string[])
|
|
409
|
+
* ```
|
|
410
|
+
*
|
|
411
|
+
* For example, extracting a single param:
|
|
412
|
+
* ```typescript
|
|
413
|
+
* findOne(@HostParam('id') id: string)
|
|
414
|
+
* ```
|
|
415
|
+
* @param property name of single property to extract from the `req` object
|
|
416
|
+
*
|
|
417
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
418
|
+
*
|
|
419
|
+
* @publicApi
|
|
420
|
+
*/
|
|
421
|
+
export declare function HostParam(): ParameterDecorator;
|
|
422
|
+
/**
|
|
423
|
+
* Route handler parameter decorator. Extracts the `hosts`
|
|
424
|
+
* property from the `req` object and populates the decorated
|
|
425
|
+
* parameter with the value of `hosts`. May also apply pipes to the bound
|
|
426
|
+
* parameter.
|
|
427
|
+
*
|
|
428
|
+
* For example, extracting all params:
|
|
429
|
+
* ```typescript
|
|
430
|
+
* findOne(@HostParam() params: string[])
|
|
431
|
+
* ```
|
|
432
|
+
*
|
|
433
|
+
* For example, extracting a single param:
|
|
434
|
+
* ```typescript
|
|
435
|
+
* findOne(@HostParam('id') id: string)
|
|
436
|
+
* ```
|
|
437
|
+
* @param property name of single property to extract from the `req` object
|
|
438
|
+
*
|
|
439
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
440
|
+
*
|
|
441
|
+
* @publicApi
|
|
442
|
+
*/
|
|
443
|
+
export declare function HostParam(property: string): ParameterDecorator;
|
|
444
|
+
export declare const Req: () => ParameterDecorator;
|
|
445
|
+
export declare const Res: (options?: ResponseDecoratorOptions) => ParameterDecorator;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Res = exports.Req = exports.Headers = exports.Session = exports.Ip = exports.Next = exports.Response = exports.Request = void 0;
|
|
4
|
+
exports.assignMetadata = assignMetadata;
|
|
5
|
+
exports.UploadedFile = UploadedFile;
|
|
6
|
+
exports.UploadedFiles = UploadedFiles;
|
|
7
|
+
exports.Query = Query;
|
|
8
|
+
exports.Body = Body;
|
|
9
|
+
exports.RawBody = RawBody;
|
|
10
|
+
exports.Param = Param;
|
|
11
|
+
exports.HostParam = HostParam;
|
|
12
|
+
const constants_1 = require("../../constants");
|
|
13
|
+
const route_paramtypes_enum_1 = require("../../enums/route-paramtypes.enum");
|
|
14
|
+
const shared_utils_1 = require("../../utils/shared.utils");
|
|
15
|
+
function assignMetadata(args, paramtype, index, data, ...pipes) {
|
|
16
|
+
return {
|
|
17
|
+
...args,
|
|
18
|
+
[`${paramtype}:${index}`]: {
|
|
19
|
+
index,
|
|
20
|
+
data,
|
|
21
|
+
pipes,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function createRouteParamDecorator(paramtype) {
|
|
26
|
+
return (data) => (target, key, index) => {
|
|
27
|
+
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) ||
|
|
28
|
+
{};
|
|
29
|
+
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target.constructor, key);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (target, key, index) => {
|
|
33
|
+
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
|
|
34
|
+
const hasParamData = (0, shared_utils_1.isNil)(data) || (0, shared_utils_1.isString)(data);
|
|
35
|
+
const paramData = hasParamData ? data : undefined;
|
|
36
|
+
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
37
|
+
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target.constructor, key);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Route handler parameter decorator. Extracts the `Request`
|
|
41
|
+
* object from the underlying platform and populates the decorated
|
|
42
|
+
* parameter with the value of `Request`.
|
|
43
|
+
*
|
|
44
|
+
* Example: `logout(@Request() req)`
|
|
45
|
+
*
|
|
46
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
47
|
+
*
|
|
48
|
+
* @publicApi
|
|
49
|
+
*/
|
|
50
|
+
exports.Request = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.REQUEST);
|
|
51
|
+
/**
|
|
52
|
+
* Route handler parameter decorator. Extracts the `Response`
|
|
53
|
+
* object from the underlying platform and populates the decorated
|
|
54
|
+
* parameter with the value of `Response`.
|
|
55
|
+
*
|
|
56
|
+
* Example: `logout(@Response() res)`
|
|
57
|
+
*
|
|
58
|
+
* @publicApi
|
|
59
|
+
*/
|
|
60
|
+
const Response = (options) => (target, key, index) => {
|
|
61
|
+
if (options?.passthrough) {
|
|
62
|
+
Reflect.defineMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, options?.passthrough, target.constructor, key);
|
|
63
|
+
}
|
|
64
|
+
return createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RESPONSE)()(target, key, index);
|
|
65
|
+
};
|
|
66
|
+
exports.Response = Response;
|
|
67
|
+
/**
|
|
68
|
+
* Route handler parameter decorator. Extracts reference to the `Next` function
|
|
69
|
+
* from the underlying platform and populates the decorated
|
|
70
|
+
* parameter with the value of `Next`.
|
|
71
|
+
*
|
|
72
|
+
* @publicApi
|
|
73
|
+
*/
|
|
74
|
+
exports.Next = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.NEXT);
|
|
75
|
+
/**
|
|
76
|
+
* Route handler parameter decorator. Extracts the `Ip` property
|
|
77
|
+
* from the `req` object and populates the decorated
|
|
78
|
+
* parameter with the value of `ip`.
|
|
79
|
+
*
|
|
80
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
81
|
+
*
|
|
82
|
+
* @publicApi
|
|
83
|
+
*/
|
|
84
|
+
exports.Ip = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.IP);
|
|
85
|
+
/**
|
|
86
|
+
* Route handler parameter decorator. Extracts the `Session` object
|
|
87
|
+
* from the underlying platform and populates the decorated
|
|
88
|
+
* parameter with the value of `Session`.
|
|
89
|
+
*
|
|
90
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
91
|
+
*
|
|
92
|
+
* @publicApi
|
|
93
|
+
*/
|
|
94
|
+
exports.Session = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.SESSION);
|
|
95
|
+
/**
|
|
96
|
+
* Route handler parameter decorator. Extracts the `file` object
|
|
97
|
+
* and populates the decorated parameter with the value of `file`.
|
|
98
|
+
* Used in conjunction with
|
|
99
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
100
|
+
*
|
|
101
|
+
* For example:
|
|
102
|
+
* ```typescript
|
|
103
|
+
* uploadFile(@UploadedFile() file) {
|
|
104
|
+
* console.log(file);
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
108
|
+
*
|
|
109
|
+
* @publicApi
|
|
110
|
+
*/
|
|
111
|
+
function UploadedFile(fileKey, ...pipes) {
|
|
112
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILE)(fileKey, ...pipes);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Route handler parameter decorator. Extracts the `files` object
|
|
116
|
+
* and populates the decorated parameter with the value of `files`.
|
|
117
|
+
* Used in conjunction with
|
|
118
|
+
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
|
|
119
|
+
*
|
|
120
|
+
* For example:
|
|
121
|
+
* ```typescript
|
|
122
|
+
* uploadFile(@UploadedFiles() files) {
|
|
123
|
+
* console.log(files);
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
|
|
127
|
+
*
|
|
128
|
+
* @publicApi
|
|
129
|
+
*/
|
|
130
|
+
function UploadedFiles(...pipes) {
|
|
131
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILES)(undefined, ...pipes);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Route handler parameter decorator. Extracts the `headers`
|
|
135
|
+
* property from the `req` object and populates the decorated
|
|
136
|
+
* parameter with the value of `headers`.
|
|
137
|
+
*
|
|
138
|
+
* For example: `async update(@Headers('Cache-Control') cacheControl: string)`
|
|
139
|
+
*
|
|
140
|
+
* @param property name of single header property to extract.
|
|
141
|
+
*
|
|
142
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
143
|
+
*
|
|
144
|
+
* @publicApi
|
|
145
|
+
*/
|
|
146
|
+
exports.Headers = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.HEADERS);
|
|
147
|
+
/**
|
|
148
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
149
|
+
* property from the `req` object and populates the decorated
|
|
150
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
151
|
+
* query parameter.
|
|
152
|
+
*
|
|
153
|
+
* For example:
|
|
154
|
+
* ```typescript
|
|
155
|
+
* async find(@Query('user') user: string)
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @param property name of single property to extract from the `query` object
|
|
159
|
+
* @param pipes one or more pipes to apply to the bound query parameter
|
|
160
|
+
*
|
|
161
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
162
|
+
*
|
|
163
|
+
* @publicApi
|
|
164
|
+
*/
|
|
165
|
+
function Query(property, ...pipes) {
|
|
166
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.QUERY)(property, ...pipes);
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Route handler parameter decorator. Extracts the entire `body` object
|
|
170
|
+
* property, or optionally a named property of the `body` object, from
|
|
171
|
+
* the `req` object and populates the decorated parameter with that value.
|
|
172
|
+
* Also applies pipes to the bound body parameter.
|
|
173
|
+
*
|
|
174
|
+
* For example:
|
|
175
|
+
* ```typescript
|
|
176
|
+
* async create(@Body('role', new ValidationPipe()) role: string)
|
|
177
|
+
* ```
|
|
178
|
+
*
|
|
179
|
+
* @param property name of single property to extract from the `body` object
|
|
180
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
181
|
+
* the bound body parameter.
|
|
182
|
+
*
|
|
183
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
184
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
185
|
+
*
|
|
186
|
+
* @publicApi
|
|
187
|
+
*/
|
|
188
|
+
function Body(property, ...pipes) {
|
|
189
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.BODY)(property, ...pipes);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
|
|
193
|
+
* property from the `req` object and populates the decorated parameter with that value.
|
|
194
|
+
* Also applies pipes to the bound rawBody parameter.
|
|
195
|
+
*
|
|
196
|
+
* For example:
|
|
197
|
+
* ```typescript
|
|
198
|
+
* async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
202
|
+
* the bound body parameter.
|
|
203
|
+
*
|
|
204
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
205
|
+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
|
|
206
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
207
|
+
*
|
|
208
|
+
* @publicApi
|
|
209
|
+
*/
|
|
210
|
+
function RawBody(...pipes) {
|
|
211
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RAW_BODY)(undefined, ...pipes);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
215
|
+
* property from the `req` object and populates the decorated
|
|
216
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
217
|
+
* parameter.
|
|
218
|
+
*
|
|
219
|
+
* For example, extracting all params:
|
|
220
|
+
* ```typescript
|
|
221
|
+
* findOne(@Param() params: string[])
|
|
222
|
+
* ```
|
|
223
|
+
*
|
|
224
|
+
* For example, extracting a single param:
|
|
225
|
+
* ```typescript
|
|
226
|
+
* findOne(@Param('id') id: string)
|
|
227
|
+
* ```
|
|
228
|
+
* @param property name of single property to extract from the `req` object
|
|
229
|
+
* @param pipes one or more pipes - either instances or classes - to apply to
|
|
230
|
+
* the bound parameter.
|
|
231
|
+
*
|
|
232
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
233
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
234
|
+
*
|
|
235
|
+
* @publicApi
|
|
236
|
+
*/
|
|
237
|
+
function Param(property, ...pipes) {
|
|
238
|
+
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.PARAM)(property, ...pipes);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Route handler parameter decorator. Extracts the `hosts`
|
|
242
|
+
* property from the `req` object and populates the decorated
|
|
243
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
244
|
+
* parameter.
|
|
245
|
+
*
|
|
246
|
+
* For example, extracting all params:
|
|
247
|
+
* ```typescript
|
|
248
|
+
* findOne(@HostParam() params: string[])
|
|
249
|
+
* ```
|
|
250
|
+
*
|
|
251
|
+
* For example, extracting a single param:
|
|
252
|
+
* ```typescript
|
|
253
|
+
* findOne(@HostParam('id') id: string)
|
|
254
|
+
* ```
|
|
255
|
+
* @param property name of single property to extract from the `req` object
|
|
256
|
+
*
|
|
257
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
258
|
+
*
|
|
259
|
+
* @publicApi
|
|
260
|
+
*/
|
|
261
|
+
function HostParam(property) {
|
|
262
|
+
return createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.HOST)(property);
|
|
263
|
+
}
|
|
264
|
+
exports.Req = exports.Request;
|
|
265
|
+
exports.Res = exports.Response;
|