@nestjs/common 11.1.16 → 12.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants.js +35 -38
- package/decorators/core/apply-decorators.js +1 -4
- package/decorators/core/bind.decorator.js +1 -4
- package/decorators/core/catch.decorator.d.ts +1 -1
- package/decorators/core/catch.decorator.js +4 -7
- package/decorators/core/controller.decorator.d.ts +1 -1
- package/decorators/core/controller.decorator.js +10 -13
- package/decorators/core/dependencies.decorator.js +4 -9
- package/decorators/core/exception-filters.decorator.d.ts +1 -1
- package/decorators/core/exception-filters.decorator.js +10 -14
- package/decorators/core/index.d.ts +14 -14
- package/decorators/core/index.js +14 -17
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/inject.decorator.js +9 -12
- package/decorators/core/injectable.decorator.d.ts +2 -2
- package/decorators/core/injectable.decorator.js +7 -11
- package/decorators/core/optional.decorator.js +8 -11
- package/decorators/core/set-metadata.decorator.js +1 -5
- package/decorators/core/use-guards.decorator.d.ts +1 -1
- package/decorators/core/use-guards.decorator.js +10 -13
- package/decorators/core/use-interceptors.decorator.d.ts +1 -1
- package/decorators/core/use-interceptors.decorator.js +10 -13
- package/decorators/core/use-pipes.decorator.d.ts +1 -1
- package/decorators/core/use-pipes.decorator.js +9 -12
- package/decorators/core/version.decorator.d.ts +1 -1
- package/decorators/core/version.decorator.js +3 -6
- package/decorators/http/create-route-param-metadata.decorator.d.ts +6 -5
- package/decorators/http/create-route-param-metadata.decorator.js +48 -16
- package/decorators/http/header.decorator.js +4 -7
- package/decorators/http/http-code.decorator.js +3 -6
- package/decorators/http/index.d.ts +8 -8
- package/decorators/http/index.js +8 -11
- package/decorators/http/redirect.decorator.js +3 -6
- package/decorators/http/render.decorator.js +3 -6
- package/decorators/http/request-mapping.decorator.d.ts +1 -1
- package/decorators/http/request-mapping.decorator.js +28 -32
- package/decorators/http/route-params.decorator.d.ts +153 -3
- package/decorators/http/route-params.decorator.js +124 -49
- package/decorators/http/sse.decorator.d.ts +2 -2
- package/decorators/http/sse.decorator.js +7 -10
- package/decorators/index.d.ts +3 -3
- package/decorators/index.js +3 -6
- package/decorators/modules/global.decorator.js +3 -6
- package/decorators/modules/index.d.ts +2 -2
- package/decorators/modules/index.js +2 -5
- package/decorators/modules/module.decorator.d.ts +1 -1
- package/decorators/modules/module.decorator.js +3 -6
- package/enums/http-status.enum.js +2 -5
- package/enums/index.d.ts +4 -4
- package/enums/index.js +4 -7
- package/enums/request-method.enum.js +2 -5
- package/enums/route-paramtypes.enum.js +2 -5
- package/enums/shutdown-signal.enum.js +2 -5
- package/enums/version-type.enum.js +2 -5
- package/exceptions/bad-gateway.exception.d.ts +1 -1
- package/exceptions/bad-gateway.exception.js +5 -9
- package/exceptions/bad-request.exception.d.ts +1 -1
- package/exceptions/bad-request.exception.js +5 -9
- package/exceptions/conflict.exception.d.ts +1 -1
- package/exceptions/conflict.exception.js +5 -9
- package/exceptions/forbidden.exception.d.ts +1 -1
- package/exceptions/forbidden.exception.js +5 -9
- package/exceptions/gateway-timeout.exception.d.ts +1 -1
- package/exceptions/gateway-timeout.exception.js +5 -9
- package/exceptions/gone.exception.d.ts +1 -1
- package/exceptions/gone.exception.js +5 -9
- package/exceptions/http-version-not-supported.exception.d.ts +1 -1
- package/exceptions/http-version-not-supported.exception.js +5 -9
- package/exceptions/http.exception.d.ts +6 -2
- package/exceptions/http.exception.js +36 -17
- package/exceptions/im-a-teapot.exception.d.ts +1 -1
- package/exceptions/im-a-teapot.exception.js +5 -9
- package/exceptions/index.d.ts +23 -23
- package/exceptions/index.js +23 -26
- package/exceptions/internal-server-error.exception.d.ts +1 -1
- package/exceptions/internal-server-error.exception.js +5 -9
- package/exceptions/intrinsic.exception.js +1 -5
- package/exceptions/method-not-allowed.exception.d.ts +1 -1
- package/exceptions/method-not-allowed.exception.js +5 -9
- package/exceptions/misdirected.exception.d.ts +1 -1
- package/exceptions/misdirected.exception.js +5 -9
- package/exceptions/not-acceptable.exception.d.ts +1 -1
- package/exceptions/not-acceptable.exception.js +5 -9
- package/exceptions/not-found.exception.d.ts +1 -1
- package/exceptions/not-found.exception.js +5 -9
- package/exceptions/not-implemented.exception.d.ts +1 -1
- package/exceptions/not-implemented.exception.js +5 -9
- package/exceptions/payload-too-large.exception.d.ts +1 -1
- package/exceptions/payload-too-large.exception.js +5 -9
- package/exceptions/precondition-failed.exception.d.ts +1 -1
- package/exceptions/precondition-failed.exception.js +5 -9
- package/exceptions/request-timeout.exception.d.ts +1 -1
- package/exceptions/request-timeout.exception.js +5 -9
- package/exceptions/service-unavailable.exception.d.ts +1 -1
- package/exceptions/service-unavailable.exception.js +5 -9
- package/exceptions/unauthorized.exception.d.ts +1 -1
- package/exceptions/unauthorized.exception.js +5 -9
- package/exceptions/unprocessable-entity.exception.d.ts +1 -1
- package/exceptions/unprocessable-entity.exception.js +5 -9
- package/exceptions/unsupported-media-type.exception.d.ts +1 -1
- package/exceptions/unsupported-media-type.exception.js +5 -9
- package/file-stream/index.d.ts +1 -1
- package/file-stream/index.js +1 -4
- package/file-stream/interfaces/index.d.ts +2 -2
- package/file-stream/interfaces/index.js +2 -5
- package/file-stream/interfaces/streamable-handler-response.interface.js +1 -2
- package/file-stream/interfaces/streamable-options.interface.js +1 -2
- package/file-stream/streamable-file.d.ts +2 -2
- package/file-stream/streamable-file.js +26 -28
- package/index.d.ts +10 -10
- package/index.js +11 -17
- package/interfaces/abstract.interface.js +1 -2
- package/interfaces/controllers/controller-metadata.interface.js +1 -2
- package/interfaces/controllers/controller.interface.js +1 -2
- package/interfaces/controllers/index.d.ts +2 -2
- package/interfaces/controllers/index.js +2 -5
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/exception-filter.interface.js +1 -2
- package/interfaces/exceptions/index.d.ts +5 -5
- package/interfaces/exceptions/index.js +5 -8
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/rpc-exception-filter.interface.js +1 -2
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/ws-exception-filter.interface.js +1 -2
- package/interfaces/external/class-transform-options.interface.js +1 -2
- package/interfaces/external/cors-options.interface.js +1 -2
- package/interfaces/external/https-options.interface.js +1 -2
- package/interfaces/external/transformer-package.interface.d.ts +2 -2
- package/interfaces/external/transformer-package.interface.js +1 -2
- package/interfaces/external/validation-error.interface.js +1 -2
- package/interfaces/external/validator-options.interface.js +1 -2
- package/interfaces/external/validator-package.interface.d.ts +2 -2
- package/interfaces/external/validator-package.interface.js +1 -2
- package/interfaces/features/arguments-host.interface.js +1 -2
- package/interfaces/features/can-activate.interface.d.ts +1 -1
- package/interfaces/features/can-activate.interface.js +1 -2
- package/interfaces/features/custom-route-param-factory.interface.d.ts +1 -1
- package/interfaces/features/custom-route-param-factory.interface.js +1 -2
- package/interfaces/features/execution-context.interface.d.ts +2 -2
- package/interfaces/features/execution-context.interface.js +1 -2
- package/interfaces/features/nest-interceptor.interface.d.ts +1 -1
- package/interfaces/features/nest-interceptor.interface.js +1 -2
- package/interfaces/features/paramtype.interface.js +1 -2
- package/interfaces/features/pipe-transform.interface.d.ts +10 -4
- package/interfaces/features/pipe-transform.interface.js +1 -2
- package/interfaces/global-prefix-options.interface.d.ts +1 -1
- package/interfaces/global-prefix-options.interface.js +1 -2
- package/interfaces/hooks/before-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/index.d.ts +5 -5
- package/interfaces/hooks/index.js +5 -8
- package/interfaces/hooks/on-application-bootstrap.interface.js +1 -2
- package/interfaces/hooks/on-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/on-destroy.interface.js +1 -2
- package/interfaces/hooks/on-init.interface.js +1 -2
- package/interfaces/http/http-exception-body.interface.d.ts +2 -1
- package/interfaces/http/http-exception-body.interface.js +1 -2
- package/interfaces/http/http-redirect-response.interface.d.ts +1 -1
- package/interfaces/http/http-redirect-response.interface.js +1 -2
- package/interfaces/http/http-server.interface.d.ts +4 -3
- package/interfaces/http/http-server.interface.js +1 -2
- package/interfaces/http/index.d.ts +5 -5
- package/interfaces/http/index.js +5 -8
- package/interfaces/http/message-event.interface.js +1 -2
- package/interfaces/http/raw-body-request.interface.js +1 -2
- package/interfaces/index.d.ts +31 -30
- package/interfaces/index.js +31 -33
- package/interfaces/injectable.interface.js +1 -2
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +1 -2
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +1 -1
- package/interfaces/microservices/nest-microservice-options.interface.js +1 -2
- package/interfaces/microservices/pre-request-hook.interface.d.ts +22 -0
- package/interfaces/microservices/pre-request-hook.interface.js +1 -0
- package/interfaces/middleware/index.d.ts +4 -4
- package/interfaces/middleware/index.js +4 -7
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-config-proxy.interface.js +1 -2
- package/interfaces/middleware/middleware-configuration.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-configuration.interface.js +1 -2
- package/interfaces/middleware/middleware-consumer.interface.d.ts +2 -2
- package/interfaces/middleware/middleware-consumer.interface.js +1 -2
- package/interfaces/middleware/nest-middleware.interface.js +1 -2
- package/interfaces/modules/dynamic-module.interface.d.ts +2 -2
- package/interfaces/modules/dynamic-module.interface.js +1 -2
- package/interfaces/modules/forward-reference.interface.js +1 -2
- package/interfaces/modules/index.d.ts +8 -8
- package/interfaces/modules/index.js +8 -11
- package/interfaces/modules/injection-token.interface.d.ts +2 -2
- package/interfaces/modules/injection-token.interface.js +1 -2
- package/interfaces/modules/introspection-result.interface.d.ts +1 -1
- package/interfaces/modules/introspection-result.interface.js +1 -2
- package/interfaces/modules/module-metadata.interface.d.ts +5 -5
- package/interfaces/modules/module-metadata.interface.js +1 -2
- package/interfaces/modules/nest-module.interface.d.ts +1 -1
- package/interfaces/modules/nest-module.interface.js +1 -2
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +1 -1
- package/interfaces/modules/optional-factory-dependency.interface.js +1 -2
- package/interfaces/modules/provider.interface.d.ts +4 -4
- package/interfaces/modules/provider.interface.js +1 -2
- package/interfaces/nest-application-context-options.interface.d.ts +1 -1
- package/interfaces/nest-application-context-options.interface.js +55 -5
- package/interfaces/nest-application-context.interface.d.ts +6 -6
- package/interfaces/nest-application-context.interface.js +1 -2
- package/interfaces/nest-application-options.interface.d.ts +9 -3
- package/interfaces/nest-application-options.interface.js +1 -2
- package/interfaces/nest-application.interface.d.ts +8 -8
- package/interfaces/nest-application.interface.js +1 -2
- package/interfaces/nest-microservice.interface.d.ts +15 -6
- package/interfaces/nest-microservice.interface.js +1 -2
- package/interfaces/scope-options.interface.js +2 -5
- package/interfaces/shutdown-hooks-options.interface.js +1 -2
- package/interfaces/type.interface.js +1 -2
- package/interfaces/version-options.interface.d.ts +1 -1
- package/interfaces/version-options.interface.js +1 -4
- package/interfaces/websockets/web-socket-adapter.interface.js +1 -2
- package/internal.d.ts +30 -0
- package/internal.js +19 -0
- package/module-utils/configurable-module.builder.d.ts +4 -4
- package/module-utils/configurable-module.builder.js +21 -20
- package/module-utils/constants.js +5 -8
- package/module-utils/index.d.ts +2 -2
- package/module-utils/index.js +2 -5
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +3 -3
- package/module-utils/interfaces/configurable-module-cls.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-host.interface.js +1 -2
- package/module-utils/interfaces/index.d.ts +3 -3
- package/module-utils/interfaces/index.js +3 -6
- package/module-utils/utils/generate-options-injection-token.util.js +3 -6
- package/module-utils/utils/get-injection-providers.util.d.ts +1 -1
- package/module-utils/utils/get-injection-providers.util.js +4 -7
- package/module-utils/utils/index.d.ts +2 -2
- package/module-utils/utils/index.js +2 -5
- package/package.json +35 -2
- package/pipes/default-value.pipe.d.ts +1 -1
- package/pipes/default-value.pipe.js +10 -12
- package/pipes/file/file-type.validator.d.ts +3 -3
- package/pipes/file/file-type.validator.js +5 -19
- package/pipes/file/file-validator-context.interface.d.ts +1 -1
- package/pipes/file/file-validator-context.interface.js +1 -2
- package/pipes/file/file-validator.interface.d.ts +1 -1
- package/pipes/file/file-validator.interface.js +2 -5
- package/pipes/file/index.d.ts +6 -6
- package/pipes/file/index.js +6 -9
- package/pipes/file/interfaces/file.interface.js +1 -2
- package/pipes/file/interfaces/index.d.ts +1 -1
- package/pipes/file/interfaces/index.js +1 -4
- package/pipes/file/max-file-size.validator.d.ts +3 -3
- package/pipes/file/max-file-size.validator.js +2 -6
- package/pipes/file/parse-file-options.interface.d.ts +2 -2
- package/pipes/file/parse-file-options.interface.js +1 -2
- package/pipes/file/parse-file-pipe.builder.d.ts +5 -5
- package/pipes/file/parse-file-pipe.builder.js +8 -14
- package/pipes/file/parse-file.pipe.d.ts +7 -7
- package/pipes/file/parse-file.pipe.js +17 -18
- package/pipes/index.d.ts +11 -10
- package/pipes/index.js +11 -13
- package/pipes/parse-array.pipe.d.ts +4 -4
- package/pipes/parse-array.pipe.js +23 -23
- package/pipes/parse-bool.pipe.d.ts +6 -6
- package/pipes/parse-bool.pipe.js +16 -17
- package/pipes/parse-date.pipe.d.ts +4 -4
- package/pipes/parse-date.pipe.js +17 -16
- package/pipes/parse-enum.pipe.d.ts +5 -5
- package/pipes/parse-enum.pipe.js +16 -16
- package/pipes/parse-float.pipe.d.ts +6 -6
- package/pipes/parse-float.pipe.js +17 -18
- package/pipes/parse-int.pipe.d.ts +5 -5
- package/pipes/parse-int.pipe.js +18 -19
- package/pipes/parse-uuid.pipe.d.ts +4 -4
- package/pipes/parse-uuid.pipe.js +27 -26
- package/pipes/standard-schema-validation.pipe.d.ts +86 -0
- package/pipes/standard-schema-validation.pipe.js +120 -0
- package/pipes/validation.pipe.d.ts +32 -14
- package/pipes/validation.pipe.js +60 -30
- package/serializer/class-serializer.constants.js +1 -4
- package/serializer/class-serializer.interceptor.d.ts +5 -5
- package/serializer/class-serializer.interceptor.js +21 -24
- package/serializer/class-serializer.interfaces.d.ts +2 -2
- package/serializer/class-serializer.interfaces.js +1 -2
- package/serializer/decorators/index.d.ts +1 -1
- package/serializer/decorators/index.js +1 -4
- package/serializer/decorators/serialize-options.decorator.d.ts +3 -2
- package/serializer/decorators/serialize-options.decorator.js +3 -7
- package/serializer/index.d.ts +5 -3
- package/serializer/index.js +5 -6
- package/serializer/standard-schema-serializer.interceptor.d.ts +50 -0
- package/serializer/standard-schema-serializer.interceptor.js +75 -0
- package/serializer/standard-schema-serializer.interfaces.d.ts +18 -0
- package/serializer/standard-schema-serializer.interfaces.js +1 -0
- package/services/console-logger.service.d.ts +22 -3
- package/services/console-logger.service.js +132 -66
- package/services/index.d.ts +3 -3
- package/services/index.js +3 -6
- package/services/logger.service.js +86 -83
- package/services/utils/filter-log-levels.util.d.ts +1 -1
- package/services/utils/filter-log-levels.util.js +7 -10
- package/services/utils/index.d.ts +3 -3
- package/services/utils/index.js +3 -6
- package/services/utils/is-log-level-enabled.util.d.ts +1 -1
- package/services/utils/is-log-level-enabled.util.js +1 -4
- package/services/utils/is-log-level.util.d.ts +1 -1
- package/services/utils/is-log-level.util.js +3 -6
- package/tsconfig.build.json +1 -2
- package/utils/assign-custom-metadata.util.d.ts +5 -4
- package/utils/assign-custom-metadata.util.js +4 -6
- package/utils/cli-colors.util.js +4 -8
- package/utils/extend-metadata.util.js +1 -4
- package/utils/forward-ref.util.d.ts +1 -1
- package/utils/forward-ref.util.js +1 -5
- package/utils/http-error-by-code.util.d.ts +2 -2
- package/utils/http-error-by-code.util.js +22 -25
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -4
- package/utils/load-package.util.d.ts +21 -1
- package/utils/load-package.util.js +62 -8
- package/utils/merge-with-values.util.js +1 -5
- package/utils/random-string-generator.util.js +2 -6
- package/utils/select-exception-filter-metadata.util.d.ts +1 -1
- package/utils/select-exception-filter-metadata.util.js +1 -5
- package/utils/shared.utils.d.ts +11 -10
- package/utils/shared.utils.js +28 -30
- package/utils/validate-each.util.js +3 -7
- package/utils/validate-module-keys.util.js +8 -13
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Version = Version;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { VERSION_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Sets the version of the endpoint to the passed version
|
|
7
4
|
*
|
|
8
5
|
* @publicApi
|
|
9
6
|
*/
|
|
10
|
-
function Version(version) {
|
|
7
|
+
export function Version(version) {
|
|
11
8
|
if (Array.isArray(version)) {
|
|
12
9
|
// Drop duplicated versions
|
|
13
10
|
version = Array.from(new Set(version));
|
|
14
11
|
}
|
|
15
12
|
return (target, key, descriptor) => {
|
|
16
|
-
Reflect.defineMetadata(
|
|
13
|
+
Reflect.defineMetadata(VERSION_METADATA, version, descriptor.value);
|
|
17
14
|
return descriptor;
|
|
18
15
|
};
|
|
19
16
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { PipeTransform } from '../../index';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { PipeTransform } from '../../index.js';
|
|
2
|
+
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface.js';
|
|
3
|
+
import { Type } from '../../interfaces/index.js';
|
|
4
|
+
import { ParameterDecoratorOptions } from './route-params.decorator.js';
|
|
4
5
|
export type ParamDecoratorEnhancer = ParameterDecorator;
|
|
5
6
|
/**
|
|
6
|
-
* Defines
|
|
7
|
+
* Defines route param decorator
|
|
7
8
|
*
|
|
8
9
|
* @param factory
|
|
9
10
|
* @param enhancers
|
|
10
11
|
*
|
|
11
12
|
* @publicApi
|
|
12
13
|
*/
|
|
13
|
-
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData)[]) => ParameterDecorator;
|
|
14
|
+
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData | ParameterDecoratorOptions)[]) => ParameterDecorator;
|
|
@@ -1,32 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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");
|
|
1
|
+
import { uid } from 'uid';
|
|
2
|
+
import { ROUTE_ARGS_METADATA } from '../../constants.js';
|
|
3
|
+
import { assignCustomParameterMetadata } from '../../utils/assign-custom-metadata.util.js';
|
|
4
|
+
import { isFunction, isNil } from '../../utils/shared.utils.js';
|
|
8
5
|
/**
|
|
9
|
-
* Defines
|
|
6
|
+
* Defines route param decorator
|
|
10
7
|
*
|
|
11
8
|
* @param factory
|
|
12
9
|
* @param enhancers
|
|
13
10
|
*
|
|
14
11
|
* @publicApi
|
|
15
12
|
*/
|
|
16
|
-
function createParamDecorator(factory, enhancers = []) {
|
|
17
|
-
const paramtype =
|
|
13
|
+
export function createParamDecorator(factory, enhancers = []) {
|
|
14
|
+
const paramtype = uid(21);
|
|
18
15
|
return (data, ...pipes) => (target, key, index) => {
|
|
19
|
-
const args = Reflect.getMetadata(
|
|
16
|
+
const args = Reflect.getMetadata(ROUTE_ARGS_METADATA, target.constructor, key) ||
|
|
20
17
|
{};
|
|
21
18
|
const isPipe = (pipe) => pipe &&
|
|
22
|
-
((
|
|
19
|
+
((isFunction(pipe) &&
|
|
23
20
|
pipe.prototype &&
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
21
|
+
isFunction(pipe.prototype.transform)) ||
|
|
22
|
+
isFunction(pipe.transform));
|
|
23
|
+
const isParameterDecoratorOptions = (value) => value &&
|
|
24
|
+
typeof value === 'object' &&
|
|
25
|
+
!isPipe(value) &&
|
|
26
|
+
('schema' in value || 'pipes' in value);
|
|
27
|
+
const hasParamData = isNil(data) || !isPipe(data);
|
|
27
28
|
const paramData = hasParamData ? data : undefined;
|
|
28
29
|
const paramPipes = hasParamData ? pipes : [data, ...pipes];
|
|
29
|
-
|
|
30
|
+
// Check if data itself is an options object (when used as the first and only argument)
|
|
31
|
+
const isDataOptions = hasParamData &&
|
|
32
|
+
!isNil(data) &&
|
|
33
|
+
paramPipes.length === 0 &&
|
|
34
|
+
isParameterDecoratorOptions(data);
|
|
35
|
+
// Check if the last pipe argument is actually an options object
|
|
36
|
+
const lastPipeArg = paramPipes.length > 0 ? paramPipes[paramPipes.length - 1] : undefined;
|
|
37
|
+
const isLastPipeOptions = !isDataOptions && isParameterDecoratorOptions(lastPipeArg);
|
|
38
|
+
let finalData;
|
|
39
|
+
let finalSchema;
|
|
40
|
+
let finalPipes;
|
|
41
|
+
if (isDataOptions) {
|
|
42
|
+
const opts = data;
|
|
43
|
+
finalData = undefined;
|
|
44
|
+
finalSchema = opts.schema;
|
|
45
|
+
finalPipes = (opts.pipes ?? []);
|
|
46
|
+
}
|
|
47
|
+
else if (isLastPipeOptions) {
|
|
48
|
+
const opts = lastPipeArg;
|
|
49
|
+
finalData = paramData;
|
|
50
|
+
finalSchema = opts.schema;
|
|
51
|
+
finalPipes = [
|
|
52
|
+
...paramPipes.slice(0, -1),
|
|
53
|
+
...(opts.pipes ?? []),
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
finalData = paramData;
|
|
58
|
+
finalSchema = undefined;
|
|
59
|
+
finalPipes = paramPipes;
|
|
60
|
+
}
|
|
61
|
+
Reflect.defineMetadata(ROUTE_ARGS_METADATA, assignCustomParameterMetadata(args, paramtype, index, factory, finalData, finalSchema, ...finalPipes), target.constructor, key);
|
|
30
62
|
enhancers.forEach(fn => fn(target, key, index));
|
|
31
63
|
};
|
|
32
64
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Header = Header;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
1
|
+
import { HEADERS_METADATA } from '../../constants.js';
|
|
2
|
+
import { extendArrayMetadata } from '../../utils/extend-metadata.util.js';
|
|
6
3
|
/**
|
|
7
4
|
* Request method Decorator. Sets a response header.
|
|
8
5
|
*
|
|
@@ -17,9 +14,9 @@ const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
|
|
|
17
14
|
*
|
|
18
15
|
* @publicApi
|
|
19
16
|
*/
|
|
20
|
-
function Header(name, value) {
|
|
17
|
+
export function Header(name, value) {
|
|
21
18
|
return (target, key, descriptor) => {
|
|
22
|
-
|
|
19
|
+
extendArrayMetadata(HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
23
20
|
return descriptor;
|
|
24
21
|
};
|
|
25
22
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpCode = HttpCode;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { HTTP_CODE_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
7
4
|
* default status code for the decorated request method.
|
|
@@ -12,9 +9,9 @@ const constants_1 = require("../../constants");
|
|
|
12
9
|
*
|
|
13
10
|
* @publicApi
|
|
14
11
|
*/
|
|
15
|
-
function HttpCode(statusCode) {
|
|
12
|
+
export function HttpCode(statusCode) {
|
|
16
13
|
return (target, key, descriptor) => {
|
|
17
|
-
Reflect.defineMetadata(
|
|
14
|
+
Reflect.defineMetadata(HTTP_CODE_METADATA, statusCode, descriptor.value);
|
|
18
15
|
return descriptor;
|
|
19
16
|
};
|
|
20
17
|
}
|
|
@@ -1,8 +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';
|
|
1
|
+
export * from './request-mapping.decorator.js';
|
|
2
|
+
export * from './route-params.decorator.js';
|
|
3
|
+
export * from './http-code.decorator.js';
|
|
4
|
+
export * from './create-route-param-metadata.decorator.js';
|
|
5
|
+
export * from './render.decorator.js';
|
|
6
|
+
export * from './header.decorator.js';
|
|
7
|
+
export * from './redirect.decorator.js';
|
|
8
|
+
export * from './sse.decorator.js';
|
package/decorators/http/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tslib_1.__exportStar(require("./header.decorator"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./redirect.decorator"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./sse.decorator"), exports);
|
|
1
|
+
export * from './request-mapping.decorator.js';
|
|
2
|
+
export * from './route-params.decorator.js';
|
|
3
|
+
export * from './http-code.decorator.js';
|
|
4
|
+
export * from './create-route-param-metadata.decorator.js';
|
|
5
|
+
export * from './render.decorator.js';
|
|
6
|
+
export * from './header.decorator.js';
|
|
7
|
+
export * from './redirect.decorator.js';
|
|
8
|
+
export * from './sse.decorator.js';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Redirect = Redirect;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { REDIRECT_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Redirects request to the specified URL.
|
|
7
4
|
*
|
|
8
5
|
* @publicApi
|
|
9
6
|
*/
|
|
10
|
-
function Redirect(url = '', statusCode) {
|
|
7
|
+
export function Redirect(url = '', statusCode) {
|
|
11
8
|
return (target, key, descriptor) => {
|
|
12
|
-
Reflect.defineMetadata(
|
|
9
|
+
Reflect.defineMetadata(REDIRECT_METADATA, { statusCode, url }, descriptor.value);
|
|
13
10
|
return descriptor;
|
|
14
11
|
};
|
|
15
12
|
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Render = Render;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
1
|
+
import { RENDER_METADATA } from '../../constants.js';
|
|
5
2
|
/**
|
|
6
3
|
* Route handler method Decorator. Defines a template to be rendered by the controller.
|
|
7
4
|
*
|
|
@@ -13,9 +10,9 @@ const constants_1 = require("../../constants");
|
|
|
13
10
|
*
|
|
14
11
|
* @publicApi
|
|
15
12
|
*/
|
|
16
|
-
function Render(template) {
|
|
13
|
+
export function Render(template) {
|
|
17
14
|
return (target, key, descriptor) => {
|
|
18
|
-
Reflect.defineMetadata(
|
|
15
|
+
Reflect.defineMetadata(RENDER_METADATA, template, descriptor.value);
|
|
19
16
|
return descriptor;
|
|
20
17
|
};
|
|
21
18
|
}
|
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Unlock = exports.Lock = exports.Move = exports.Copy = exports.Mkcol = exports.Proppatch = exports.Propfind = exports.Search = exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
|
-
const request_method_enum_1 = require("../../enums/request-method.enum");
|
|
1
|
+
import { METHOD_METADATA, PATH_METADATA } from '../../constants.js';
|
|
2
|
+
import { RequestMethod } from '../../enums/request-method.enum.js';
|
|
6
3
|
const defaultMetadata = {
|
|
7
|
-
[
|
|
8
|
-
[
|
|
4
|
+
[PATH_METADATA]: '/',
|
|
5
|
+
[METHOD_METADATA]: RequestMethod.GET,
|
|
9
6
|
};
|
|
10
|
-
const RequestMapping = (metadata = defaultMetadata) => {
|
|
11
|
-
const pathMetadata = metadata[
|
|
7
|
+
export const RequestMapping = (metadata = defaultMetadata) => {
|
|
8
|
+
const pathMetadata = metadata[PATH_METADATA];
|
|
12
9
|
const path = pathMetadata && pathMetadata.length ? pathMetadata : '/';
|
|
13
|
-
const requestMethod = metadata[
|
|
10
|
+
const requestMethod = metadata[METHOD_METADATA] || RequestMethod.GET;
|
|
14
11
|
return (target, key, descriptor) => {
|
|
15
|
-
Reflect.defineMetadata(
|
|
16
|
-
Reflect.defineMetadata(
|
|
12
|
+
Reflect.defineMetadata(PATH_METADATA, path, descriptor.value);
|
|
13
|
+
Reflect.defineMetadata(METHOD_METADATA, requestMethod, descriptor.value);
|
|
17
14
|
return descriptor;
|
|
18
15
|
};
|
|
19
16
|
};
|
|
20
|
-
exports.RequestMapping = RequestMapping;
|
|
21
17
|
const createMappingDecorator = (method) => (path) => {
|
|
22
|
-
return
|
|
23
|
-
[
|
|
24
|
-
[
|
|
18
|
+
return RequestMapping({
|
|
19
|
+
[PATH_METADATA]: path,
|
|
20
|
+
[METHOD_METADATA]: method,
|
|
25
21
|
});
|
|
26
22
|
};
|
|
27
23
|
/**
|
|
@@ -31,7 +27,7 @@ const createMappingDecorator = (method) => (path) => {
|
|
|
31
27
|
*
|
|
32
28
|
* @publicApi
|
|
33
29
|
*/
|
|
34
|
-
|
|
30
|
+
export const Post = createMappingDecorator(RequestMethod.POST);
|
|
35
31
|
/**
|
|
36
32
|
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
|
|
37
33
|
*
|
|
@@ -39,7 +35,7 @@ exports.Post = createMappingDecorator(request_method_enum_1.RequestMethod.POST);
|
|
|
39
35
|
*
|
|
40
36
|
* @publicApi
|
|
41
37
|
*/
|
|
42
|
-
|
|
38
|
+
export const Get = createMappingDecorator(RequestMethod.GET);
|
|
43
39
|
/**
|
|
44
40
|
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
|
|
45
41
|
*
|
|
@@ -47,7 +43,7 @@ exports.Get = createMappingDecorator(request_method_enum_1.RequestMethod.GET);
|
|
|
47
43
|
*
|
|
48
44
|
* @publicApi
|
|
49
45
|
*/
|
|
50
|
-
|
|
46
|
+
export const Delete = createMappingDecorator(RequestMethod.DELETE);
|
|
51
47
|
/**
|
|
52
48
|
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
|
|
53
49
|
*
|
|
@@ -55,7 +51,7 @@ exports.Delete = createMappingDecorator(request_method_enum_1.RequestMethod.DELE
|
|
|
55
51
|
*
|
|
56
52
|
* @publicApi
|
|
57
53
|
*/
|
|
58
|
-
|
|
54
|
+
export const Put = createMappingDecorator(RequestMethod.PUT);
|
|
59
55
|
/**
|
|
60
56
|
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
|
|
61
57
|
*
|
|
@@ -63,7 +59,7 @@ exports.Put = createMappingDecorator(request_method_enum_1.RequestMethod.PUT);
|
|
|
63
59
|
*
|
|
64
60
|
* @publicApi
|
|
65
61
|
*/
|
|
66
|
-
|
|
62
|
+
export const Patch = createMappingDecorator(RequestMethod.PATCH);
|
|
67
63
|
/**
|
|
68
64
|
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
|
|
69
65
|
*
|
|
@@ -71,7 +67,7 @@ exports.Patch = createMappingDecorator(request_method_enum_1.RequestMethod.PATCH
|
|
|
71
67
|
*
|
|
72
68
|
* @publicApi
|
|
73
69
|
*/
|
|
74
|
-
|
|
70
|
+
export const Options = createMappingDecorator(RequestMethod.OPTIONS);
|
|
75
71
|
/**
|
|
76
72
|
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
|
|
77
73
|
*
|
|
@@ -79,7 +75,7 @@ exports.Options = createMappingDecorator(request_method_enum_1.RequestMethod.OPT
|
|
|
79
75
|
*
|
|
80
76
|
* @publicApi
|
|
81
77
|
*/
|
|
82
|
-
|
|
78
|
+
export const Head = createMappingDecorator(RequestMethod.HEAD);
|
|
83
79
|
/**
|
|
84
80
|
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
85
81
|
*
|
|
@@ -87,7 +83,7 @@ exports.Head = createMappingDecorator(request_method_enum_1.RequestMethod.HEAD);
|
|
|
87
83
|
*
|
|
88
84
|
* @publicApi
|
|
89
85
|
*/
|
|
90
|
-
|
|
86
|
+
export const All = createMappingDecorator(RequestMethod.ALL);
|
|
91
87
|
/**
|
|
92
88
|
* Route handler (method) Decorator. Routes HTTP SEARCH requests to the specified path.
|
|
93
89
|
*
|
|
@@ -95,7 +91,7 @@ exports.All = createMappingDecorator(request_method_enum_1.RequestMethod.ALL);
|
|
|
95
91
|
*
|
|
96
92
|
* @publicApi
|
|
97
93
|
*/
|
|
98
|
-
|
|
94
|
+
export const Search = createMappingDecorator(RequestMethod.SEARCH);
|
|
99
95
|
/**
|
|
100
96
|
* Route handler (method) Decorator. Routes Webdav PROPFIND requests to the specified path.
|
|
101
97
|
*
|
|
@@ -103,7 +99,7 @@ exports.Search = createMappingDecorator(request_method_enum_1.RequestMethod.SEAR
|
|
|
103
99
|
*
|
|
104
100
|
* @publicApi
|
|
105
101
|
*/
|
|
106
|
-
|
|
102
|
+
export const Propfind = createMappingDecorator(RequestMethod.PROPFIND);
|
|
107
103
|
/**
|
|
108
104
|
* Route handler (method) Decorator. Routes Webdav PROPPATCH requests to the specified path.
|
|
109
105
|
*
|
|
@@ -111,7 +107,7 @@ exports.Propfind = createMappingDecorator(request_method_enum_1.RequestMethod.PR
|
|
|
111
107
|
*
|
|
112
108
|
* @publicApi
|
|
113
109
|
*/
|
|
114
|
-
|
|
110
|
+
export const Proppatch = createMappingDecorator(RequestMethod.PROPPATCH);
|
|
115
111
|
/**
|
|
116
112
|
* Route handler (method) Decorator. Routes Webdav MKCOL requests to the specified path.
|
|
117
113
|
*
|
|
@@ -119,7 +115,7 @@ exports.Proppatch = createMappingDecorator(request_method_enum_1.RequestMethod.P
|
|
|
119
115
|
*
|
|
120
116
|
* @publicApi
|
|
121
117
|
*/
|
|
122
|
-
|
|
118
|
+
export const Mkcol = createMappingDecorator(RequestMethod.MKCOL);
|
|
123
119
|
/**
|
|
124
120
|
* Route handler (method) Decorator. Routes Webdav COPY requests to the specified path.
|
|
125
121
|
*
|
|
@@ -127,7 +123,7 @@ exports.Mkcol = createMappingDecorator(request_method_enum_1.RequestMethod.MKCOL
|
|
|
127
123
|
*
|
|
128
124
|
* @publicApi
|
|
129
125
|
*/
|
|
130
|
-
|
|
126
|
+
export const Copy = createMappingDecorator(RequestMethod.COPY);
|
|
131
127
|
/**
|
|
132
128
|
* Route handler (method) Decorator. Routes Webdav MOVE requests to the specified path.
|
|
133
129
|
*
|
|
@@ -135,7 +131,7 @@ exports.Copy = createMappingDecorator(request_method_enum_1.RequestMethod.COPY);
|
|
|
135
131
|
*
|
|
136
132
|
* @publicApi
|
|
137
133
|
*/
|
|
138
|
-
|
|
134
|
+
export const Move = createMappingDecorator(RequestMethod.MOVE);
|
|
139
135
|
/**
|
|
140
136
|
* Route handler (method) Decorator. Routes Webdav LOCK requests to the specified path.
|
|
141
137
|
*
|
|
@@ -143,7 +139,7 @@ exports.Move = createMappingDecorator(request_method_enum_1.RequestMethod.MOVE);
|
|
|
143
139
|
*
|
|
144
140
|
* @publicApi
|
|
145
141
|
*/
|
|
146
|
-
|
|
142
|
+
export const Lock = createMappingDecorator(RequestMethod.LOCK);
|
|
147
143
|
/**
|
|
148
144
|
* Route handler (method) Decorator. Routes Webdav UNLOCK requests to the specified path.
|
|
149
145
|
*
|
|
@@ -151,4 +147,4 @@ exports.Lock = createMappingDecorator(request_method_enum_1.RequestMethod.LOCK);
|
|
|
151
147
|
*
|
|
152
148
|
* @publicApi
|
|
153
149
|
*/
|
|
154
|
-
|
|
150
|
+
export const Unlock = createMappingDecorator(RequestMethod.UNLOCK);
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { PipeTransform } from '../../index.js';
|
|
3
|
+
import { Type } from '../../interfaces/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* The options that can be passed to a handler's parameter decorator, such as `@Query()`, `@Body()`, and others.
|
|
6
|
+
* These options allow you to specify a schema for validation and transformation, as well as any pipes to apply to the parameter.
|
|
7
|
+
*/
|
|
8
|
+
export interface ParameterDecoratorOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The schema to use to retrieve within the pipes,
|
|
11
|
+
* to, for example, validate the parameter against the schema or to apply transformations based on the schema.
|
|
12
|
+
*/
|
|
13
|
+
schema?: StandardSchemaV1;
|
|
14
|
+
/**
|
|
15
|
+
* The list of pipes to apply to the parameter.
|
|
16
|
+
*/
|
|
17
|
+
pipes?: (Type<PipeTransform> | PipeTransform)[];
|
|
18
|
+
}
|
|
3
19
|
/**
|
|
4
20
|
* The `@Response()`/`@Res` parameter decorator options.
|
|
5
21
|
*/
|
|
@@ -18,8 +34,11 @@ export interface RouteParamMetadata {
|
|
|
18
34
|
index: number;
|
|
19
35
|
data?: ParamData;
|
|
20
36
|
}
|
|
21
|
-
export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number,
|
|
37
|
+
export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number, options: {
|
|
38
|
+
data?: ParamData;
|
|
39
|
+
} & ParameterDecoratorOptions): TArgs & {
|
|
22
40
|
[x: string]: {
|
|
41
|
+
schema?: StandardSchemaV1<unknown, unknown> | undefined;
|
|
23
42
|
index: number;
|
|
24
43
|
data: ParamData | undefined;
|
|
25
44
|
pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[];
|
|
@@ -231,6 +250,43 @@ export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[])
|
|
|
231
250
|
* @publicApi
|
|
232
251
|
*/
|
|
233
252
|
export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
253
|
+
/**
|
|
254
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
255
|
+
* property from the `req` object and populates the decorated
|
|
256
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
257
|
+
* query parameter.
|
|
258
|
+
*
|
|
259
|
+
* For example:
|
|
260
|
+
* ```typescript
|
|
261
|
+
* async find(@Query('user') user: string)
|
|
262
|
+
* ```
|
|
263
|
+
*
|
|
264
|
+
* @param property name of single property to extract from the `query` object
|
|
265
|
+
* @param options options object containing additional configuration for the decorator, such as pipes and schema
|
|
266
|
+
*
|
|
267
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
268
|
+
*
|
|
269
|
+
* @publicApi
|
|
270
|
+
*/
|
|
271
|
+
export declare function Query(property: string, options: ParameterDecoratorOptions): ParameterDecorator;
|
|
272
|
+
/**
|
|
273
|
+
* Route handler parameter decorator. Extracts the `query`
|
|
274
|
+
* property from the `req` object and populates the decorated
|
|
275
|
+
* parameter with the value of `query`. May also apply pipes to the bound
|
|
276
|
+
* query parameter.
|
|
277
|
+
*
|
|
278
|
+
* For example:
|
|
279
|
+
* ```typescript
|
|
280
|
+
* async find(@Query({ schema: z.object({ user: z.string() }) }) query)
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* @param options options object containing additional configuration for the decorator, such as pipes and schema
|
|
284
|
+
*
|
|
285
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
286
|
+
*
|
|
287
|
+
* @publicApi
|
|
288
|
+
*/
|
|
289
|
+
export declare function Query(options: ParameterDecoratorOptions): ParameterDecorator;
|
|
234
290
|
/**
|
|
235
291
|
* Route handler parameter decorator. Extracts the entire `body`
|
|
236
292
|
* object from the `req` object and populates the decorated
|
|
@@ -266,6 +322,23 @@ export declare function Body(): ParameterDecorator;
|
|
|
266
322
|
* @publicApi
|
|
267
323
|
*/
|
|
268
324
|
export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
325
|
+
/**
|
|
326
|
+
* Route handler parameter decorator. Extracts the entire `body` object
|
|
327
|
+
* property, or optionally a named property of the `body` object, from
|
|
328
|
+
* the `req` object and populates the decorated parameter with that value.
|
|
329
|
+
*
|
|
330
|
+
* For example:
|
|
331
|
+
* ```typescript
|
|
332
|
+
* async create(@Body('role') role: string)
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @param options options to apply to the bound body parameter.
|
|
336
|
+
*
|
|
337
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
338
|
+
*
|
|
339
|
+
* @publicApi
|
|
340
|
+
*/
|
|
341
|
+
export declare function Body(options: ParameterDecoratorOptions): ParameterDecorator;
|
|
269
342
|
/**
|
|
270
343
|
* Route handler parameter decorator. Extracts a single property from
|
|
271
344
|
* the `body` object property of the `req` object and populates the decorated
|
|
@@ -287,6 +360,26 @@ export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]):
|
|
|
287
360
|
* @publicApi
|
|
288
361
|
*/
|
|
289
362
|
export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
363
|
+
/**
|
|
364
|
+
* Route handler parameter decorator. Extracts the entire `body` object
|
|
365
|
+
* property, or optionally a named property of the `body` object, from
|
|
366
|
+
* the `req` object and populates the decorated parameter with that value.
|
|
367
|
+
* Also applies pipes to the bound body parameter.
|
|
368
|
+
*
|
|
369
|
+
* For example:
|
|
370
|
+
* ```typescript
|
|
371
|
+
* async create(@Body('role', new ValidationPipe()) role: string)
|
|
372
|
+
* ```
|
|
373
|
+
*
|
|
374
|
+
* @param property name of single property to extract from the `body` object
|
|
375
|
+
* @param options options to apply to the bound body parameter.
|
|
376
|
+
*
|
|
377
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
378
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
379
|
+
*
|
|
380
|
+
* @publicApi
|
|
381
|
+
*/
|
|
382
|
+
export declare function Body(property: string, options: ParameterDecoratorOptions): ParameterDecorator;
|
|
290
383
|
/**
|
|
291
384
|
* Route handler parameter decorator. Extracts the `rawBody` Buffer
|
|
292
385
|
* property from the `req` object and populates the decorated parameter with that value.
|
|
@@ -322,6 +415,25 @@ export declare function RawBody(): ParameterDecorator;
|
|
|
322
415
|
* @publicApi
|
|
323
416
|
*/
|
|
324
417
|
export declare function RawBody(...pipes: (Type<PipeTransform<Buffer | undefined>> | PipeTransform<Buffer | undefined>)[]): ParameterDecorator;
|
|
418
|
+
/**
|
|
419
|
+
* Route handler parameter decorator. Extracts the `rawBody` Buffer
|
|
420
|
+
* property from the `req` object and populates the decorated parameter with that value.
|
|
421
|
+
* Also applies pipes to the bound rawBody parameter.
|
|
422
|
+
*
|
|
423
|
+
* For example:
|
|
424
|
+
* ```typescript
|
|
425
|
+
* async create(@RawBody({ schema: z.instanceof(Buffer) }) rawBody: Buffer)
|
|
426
|
+
* ```
|
|
427
|
+
*
|
|
428
|
+
* @param options options object containing additional configuration for the decorator, such as pipes and schema
|
|
429
|
+
*
|
|
430
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
431
|
+
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
|
|
432
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
433
|
+
*
|
|
434
|
+
* @publicApi
|
|
435
|
+
*/
|
|
436
|
+
export declare function RawBody(options: ParameterDecoratorOptions): ParameterDecorator;
|
|
325
437
|
/**
|
|
326
438
|
* Route handler parameter decorator. Extracts the `params`
|
|
327
439
|
* property from the `req` object and populates the decorated
|
|
@@ -397,6 +509,44 @@ export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[])
|
|
|
397
509
|
* @publicApi
|
|
398
510
|
*/
|
|
399
511
|
export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
|
|
512
|
+
/**
|
|
513
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
514
|
+
* property from the `req` object and populates the decorated
|
|
515
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
516
|
+
* parameter.
|
|
517
|
+
*
|
|
518
|
+
* For example, extracting a single param:
|
|
519
|
+
* ```typescript
|
|
520
|
+
* findOne(@Param('id', { schema: z.string().uuid() }) id: string)
|
|
521
|
+
* ```
|
|
522
|
+
* @param property name of single property to extract from the `req` object
|
|
523
|
+
* @param options options object containing additional configuration for the decorator, such as pipes and schema
|
|
524
|
+
*
|
|
525
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
526
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
527
|
+
*
|
|
528
|
+
* @publicApi
|
|
529
|
+
*/
|
|
530
|
+
export declare function Param(property: string, options: ParameterDecoratorOptions): ParameterDecorator;
|
|
531
|
+
/**
|
|
532
|
+
* Route handler parameter decorator. Extracts the `params`
|
|
533
|
+
* property from the `req` object and populates the decorated
|
|
534
|
+
* parameter with the value of `params`. May also apply pipes to the bound
|
|
535
|
+
* parameter.
|
|
536
|
+
*
|
|
537
|
+
* For example:
|
|
538
|
+
* ```typescript
|
|
539
|
+
* findOne(@Param({ schema: z.object({ id: z.string().uuid() }) }) params)
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @param options options object containing additional configuration for the decorator, such as pipes and schema
|
|
543
|
+
*
|
|
544
|
+
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
|
|
545
|
+
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
|
|
546
|
+
*
|
|
547
|
+
* @publicApi
|
|
548
|
+
*/
|
|
549
|
+
export declare function Param(options: ParameterDecoratorOptions): ParameterDecorator;
|
|
400
550
|
/**
|
|
401
551
|
* Route handler parameter decorator. Extracts the `hosts`
|
|
402
552
|
* property from the `req` object and populates the decorated
|