Initial commit - Event Planner application

This commit is contained in:
mberlin
2026-03-18 14:55:56 -03:00
commit 86d779eb4d
7548 changed files with 1006324 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
/**
* Function that returns a new decorator that applies all decorators provided by param
*
* Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
*
* @param decorators one or more decorators (e.g., `ApplyGuard(...)`)
*
* @publicApi
*/
export declare function applyDecorators(...decorators: Array<ClassDecorator | MethodDecorator | PropertyDecorator>): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyDecorators = applyDecorators;
/**
* Function that returns a new decorator that applies all decorators provided by param
*
* Useful to build new decorators (or a decorator factory) encapsulating multiple decorators related with the same feature
*
* @param decorators one or more decorators (e.g., `ApplyGuard(...)`)
*
* @publicApi
*/
function applyDecorators(...decorators) {
return (target, propertyKey, descriptor) => {
for (const decorator of decorators) {
if (target instanceof Function && !descriptor) {
decorator(target);
continue;
}
decorator(target, propertyKey, descriptor);
}
};
}

View File

@@ -0,0 +1,11 @@
/**
* Decorator that binds *parameter decorators* to the method that follows.
*
* Useful when the language doesn't provide a 'Parameter Decorator' feature
* (i.e., vanilla JavaScript).
*
* @param decorators one or more parameter decorators (e.g., `Req()`)
*
* @publicApi
*/
export declare function Bind(...decorators: any[]): MethodDecorator;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Bind = Bind;
/**
* Decorator that binds *parameter decorators* to the method that follows.
*
* Useful when the language doesn't provide a 'Parameter Decorator' feature
* (i.e., vanilla JavaScript).
*
* @param decorators one or more parameter decorators (e.g., `Req()`)
*
* @publicApi
*/
function Bind(...decorators) {
return (target, key, descriptor) => {
decorators.forEach((fn, index) => fn(target, key, index));
return descriptor;
};
}

View File

@@ -0,0 +1,19 @@
import { Type, Abstract } from '../../interfaces';
/**
* Decorator that marks a class as a Nest exception filter. An exception filter
* handles exceptions thrown by or not handled by your application code.
*
* The decorated class must implement the `ExceptionFilter` interface.
*
* @param exceptions one or more exception *types* specifying
* the exceptions to be caught and handled by this filter.
*
* @see [Exception Filters](https://docs.nestjs.com/exception-filters)
*
* @usageNotes
* Exception filters are applied using the `@UseFilters()` decorator, or (globally)
* with `app.useGlobalFilters()`.
*
* @publicApi
*/
export declare function Catch(...exceptions: Array<Type<any> | Abstract<any>>): ClassDecorator;

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Catch = Catch;
const constants_1 = require("../../constants");
/**
* Decorator that marks a class as a Nest exception filter. An exception filter
* handles exceptions thrown by or not handled by your application code.
*
* The decorated class must implement the `ExceptionFilter` interface.
*
* @param exceptions one or more exception *types* specifying
* the exceptions to be caught and handled by this filter.
*
* @see [Exception Filters](https://docs.nestjs.com/exception-filters)
*
* @usageNotes
* Exception filters are applied using the `@UseFilters()` decorator, or (globally)
* with `app.useGlobalFilters()`.
*
* @publicApi
*/
function Catch(...exceptions) {
return (target) => {
Reflect.defineMetadata(constants_1.CATCH_WATERMARK, true, target);
Reflect.defineMetadata(constants_1.FILTER_CATCH_EXCEPTIONS, exceptions, target);
};
}

View File

@@ -0,0 +1,102 @@
import { ScopeOptions, VersionOptions } from '../../interfaces';
/**
* Interface defining options that can be passed to `@Controller()` decorator
*
* @publicApi
*/
export interface ControllerOptions extends ScopeOptions, VersionOptions {
/**
* Specifies an optional `route path prefix`. The prefix is pre-pended to the
* path specified in any request decorator in the class.
*
* Supported only by HTTP-based applications (does not apply to non-HTTP microservices).
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*/
path?: string | string[];
/**
* Specifies an optional HTTP Request host filter. When configured, methods
* within the controller will only be routed if the request host matches the
* specified value.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*/
host?: string | RegExp | Array<string | RegExp>;
}
/**
* Decorator that marks a class as a Nest controller that can receive inbound
* requests and produce responses.
*
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
* It defines a class that provides the context for one or more related route
* handlers that correspond to HTTP request methods and associated routes
* for example `GET /api/profile`, `POST /users/resume`.
*
* A Microservice Controller responds to requests as well as events, running over
* a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
* It defines a class that provides a context for one or more message or event
* handlers.
*
* @see [Controllers](https://docs.nestjs.com/controllers)
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
*
* @publicApi
*/
export declare function Controller(): ClassDecorator;
/**
* Decorator that marks a class as a Nest controller that can receive inbound
* requests and produce responses.
*
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
* It defines a class that provides the context for one or more related route
* handlers that correspond to HTTP request methods and associated routes
* for example `GET /api/profile`, `POST /users/resume`.
*
* A Microservice Controller responds to requests as well as events, running over
* a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
* It defines a class that provides a context for one or more message or event
* handlers.
*
* @param {string|Array} prefix string that defines a `route path prefix`. The prefix
* is pre-pended to the path specified in any request decorator in the class.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
* @see [Controllers](https://docs.nestjs.com/controllers)
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
*
* @publicApi
*/
export declare function Controller(prefix: string | string[]): ClassDecorator;
/**
* Decorator that marks a class as a Nest controller that can receive inbound
* requests and produce responses.
*
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
* It defines a class that provides the context for one or more related route
* handlers that correspond to HTTP request methods and associated routes
* for example `GET /api/profile`, `POST /users/resume`.
*
* A Microservice Controller responds to requests as well as events, running over
* a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
* It defines a class that provides a context for one or more message or event
* handlers.
*
* @param {object} options configuration object specifying:
*
* - `scope` - symbol that determines the lifetime of a Controller instance.
* [See Scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage) for
* more details.
* - `prefix` - string that defines a `route path prefix`. The prefix
* is pre-pended to the path specified in any request decorator in the class.
* - `version` - string, array of strings, or Symbol that defines the version
* of all routes in the class. [See Versioning](https://docs.nestjs.com/techniques/versioning)
* for more details.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
* @see [Controllers](https://docs.nestjs.com/controllers)
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
* @see [Versioning](https://docs.nestjs.com/techniques/versioning)
*
* @publicApi
*/
export declare function Controller(options: ControllerOptions): ClassDecorator;

View File

@@ -0,0 +1,61 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Controller = Controller;
const constants_1 = require("../../constants");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Decorator that marks a class as a Nest controller that can receive inbound
* requests and produce responses.
*
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
* It defines a class that provides the context for one or more related route
* handlers that correspond to HTTP request methods and associated routes
* for example `GET /api/profile`, `POST /users/resume`
*
* A Microservice Controller responds to requests as well as events, running over
* a variety of transports [(read more here)](https://docs.nestjs.com/microservices/basics).
* It defines a class that provides a context for one or more message or event
* handlers.
*
* @param prefixOrOptions a `route path prefix` or a `ControllerOptions` object.
* A `route path prefix` is pre-pended to the path specified in any request decorator
* in the class. `ControllerOptions` is an options configuration object specifying:
* - `scope` - symbol that determines the lifetime of a Controller instance.
* [See Scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage) for
* more details.
* - `prefix` - string that defines a `route path prefix`. The prefix
* is pre-pended to the path specified in any request decorator in the class.
* - `version` - string, array of strings, or Symbol that defines the version
* of all routes in the class. [See Versioning](https://docs.nestjs.com/techniques/versioning)
* for more details.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
* @see [Controllers](https://docs.nestjs.com/controllers)
* @see [Microservices](https://docs.nestjs.com/microservices/basics#request-response)
* @see [Scope](https://docs.nestjs.com/fundamentals/injection-scopes#usage)
* @see [Versioning](https://docs.nestjs.com/techniques/versioning)
*
* @publicApi
*/
function Controller(prefixOrOptions) {
const defaultPath = '/';
const [path, host, scopeOptions, versionOptions] = (0, shared_utils_1.isUndefined)(prefixOrOptions)
? [defaultPath, undefined, undefined, undefined]
: (0, shared_utils_1.isString)(prefixOrOptions) || Array.isArray(prefixOrOptions)
? [prefixOrOptions, undefined, undefined, undefined]
: [
prefixOrOptions.path || defaultPath,
prefixOrOptions.host,
{ scope: prefixOrOptions.scope, durable: prefixOrOptions.durable },
Array.isArray(prefixOrOptions.version)
? Array.from(new Set(prefixOrOptions.version))
: prefixOrOptions.version,
];
return (target) => {
Reflect.defineMetadata(constants_1.CONTROLLER_WATERMARK, true, target);
Reflect.defineMetadata(constants_1.PATH_METADATA, path, target);
Reflect.defineMetadata(constants_1.HOST_METADATA, host, target);
Reflect.defineMetadata(constants_1.SCOPE_OPTIONS_METADATA, scopeOptions, target);
Reflect.defineMetadata(constants_1.VERSION_METADATA, versionOptions, target);
};
}

View File

@@ -0,0 +1,7 @@
export declare function flatten<T extends Array<unknown> = any>(arr: T): T extends Array<infer R> ? R : never;
/**
* Decorator that sets required dependencies (required with a vanilla JavaScript objects)
*
* @publicApi
*/
export declare const Dependencies: (...dependencies: Array<unknown>) => ClassDecorator;

View File

@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Dependencies = void 0;
exports.flatten = flatten;
const constants_1 = require("../../constants");
function flatten(arr) {
const flat = [].concat(...arr);
return flat.some(Array.isArray)
? flatten(flat)
: flat;
}
/**
* Decorator that sets required dependencies (required with a vanilla JavaScript objects)
*
* @publicApi
*/
const Dependencies = (...dependencies) => {
const flattenDeps = flatten(dependencies);
return (target) => {
Reflect.defineMetadata(constants_1.PARAMTYPES_METADATA, flattenDeps, target);
};
};
exports.Dependencies = Dependencies;

View File

@@ -0,0 +1,23 @@
import { ExceptionFilter } from '../../index';
/**
* Decorator that binds exception filters to the scope of the controller or
* method, depending on its context.
*
* When `@UseFilters` is used at the controller level, the filter will be
* applied to every handler (method) in the controller.
*
* When `@UseFilters` is used at the individual handler level, the filter
* will apply only to that specific method.
*
* @param filters exception filter instance or class, or a list of exception
* filter instances or classes.
*
* @see [Exception filters](https://docs.nestjs.com/exception-filters)
*
* @usageNotes
* Exception filters can also be set up globally for all controllers and routes
* using `app.useGlobalFilters()`. [See here for details](https://docs.nestjs.com/exception-filters#binding-filters)
*
* @publicApi
*/
export declare const UseFilters: (...filters: (ExceptionFilter | Function)[]) => MethodDecorator & ClassDecorator;

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UseFilters = void 0;
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
/**
* Decorator that binds exception filters to the scope of the controller or
* method, depending on its context.
*
* When `@UseFilters` is used at the controller level, the filter will be
* applied to every handler (method) in the controller.
*
* When `@UseFilters` is used at the individual handler level, the filter
* will apply only to that specific method.
*
* @param filters exception filter instance or class, or a list of exception
* filter instances or classes.
*
* @see [Exception filters](https://docs.nestjs.com/exception-filters)
*
* @usageNotes
* Exception filters can also be set up globally for all controllers and routes
* using `app.useGlobalFilters()`. [See here for details](https://docs.nestjs.com/exception-filters#binding-filters)
*
* @publicApi
*/
const UseFilters = (...filters) => addExceptionFiltersMetadata(...filters);
exports.UseFilters = UseFilters;
function addExceptionFiltersMetadata(...filters) {
return (target, key, descriptor) => {
const isFilterValid = (filter) => filter && ((0, shared_utils_1.isFunction)(filter) || (0, shared_utils_1.isFunction)(filter.catch));
if (descriptor) {
(0, validate_each_util_1.validateEach)(target.constructor, filters, isFilterValid, '@UseFilters', 'filter');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.EXCEPTION_FILTERS_METADATA, filters, descriptor.value);
return descriptor;
}
(0, validate_each_util_1.validateEach)(target, filters, isFilterValid, '@UseFilters', 'filter');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.EXCEPTION_FILTERS_METADATA, filters, target);
return target;
};
}

14
node_modules/@nestjs/common/decorators/core/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export * from './bind.decorator';
export * from './catch.decorator';
export * from './controller.decorator';
export * from './dependencies.decorator';
export * from './exception-filters.decorator';
export * from './inject.decorator';
export * from './injectable.decorator';
export * from './optional.decorator';
export * from './set-metadata.decorator';
export * from './use-guards.decorator';
export * from './use-interceptors.decorator';
export * from './use-pipes.decorator';
export * from './apply-decorators';
export * from './version.decorator';

17
node_modules/@nestjs/common/decorators/core/index.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./bind.decorator"), exports);
tslib_1.__exportStar(require("./catch.decorator"), exports);
tslib_1.__exportStar(require("./controller.decorator"), exports);
tslib_1.__exportStar(require("./dependencies.decorator"), exports);
tslib_1.__exportStar(require("./exception-filters.decorator"), exports);
tslib_1.__exportStar(require("./inject.decorator"), exports);
tslib_1.__exportStar(require("./injectable.decorator"), exports);
tslib_1.__exportStar(require("./optional.decorator"), exports);
tslib_1.__exportStar(require("./set-metadata.decorator"), exports);
tslib_1.__exportStar(require("./use-guards.decorator"), exports);
tslib_1.__exportStar(require("./use-interceptors.decorator"), exports);
tslib_1.__exportStar(require("./use-pipes.decorator"), exports);
tslib_1.__exportStar(require("./apply-decorators"), exports);
tslib_1.__exportStar(require("./version.decorator"), exports);

View File

@@ -0,0 +1,31 @@
import { ForwardReference, InjectionToken } from '../../interfaces';
/**
* Decorator that marks a constructor parameter as a target for
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
*
* Any injected provider must be visible within the module scope (loosely
* speaking, the containing module) of the class it is being injected into. This
* can be done by:
*
* - defining the provider in the same module scope
* - exporting the provider from one module scope and importing that module into the
* module scope of the class being injected into
* - exporting the provider from a module that is marked as global using the
* `@Global()` decorator
*
* #### Injection tokens
* Can be *types* (class names), *strings* or *symbols*. This depends on how the
* provider with which it is associated was defined. Providers defined with the
* `@Injectable()` decorator use the class name. Custom Providers may use strings
* or symbols as the injection token.
*
* @param token lookup key for the provider to be injected (assigned to the constructor
* parameter).
*
* @see [Providers](https://docs.nestjs.com/providers)
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
*
* @publicApi
*/
export declare function Inject(token?: InjectionToken | ForwardReference): PropertyDecorator & ParameterDecorator;

View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Inject = Inject;
const constants_1 = require("../../constants");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Decorator that marks a constructor parameter as a target for
* [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
*
* Any injected provider must be visible within the module scope (loosely
* speaking, the containing module) of the class it is being injected into. This
* can be done by:
*
* - defining the provider in the same module scope
* - exporting the provider from one module scope and importing that module into the
* module scope of the class being injected into
* - exporting the provider from a module that is marked as global using the
* `@Global()` decorator
*
* #### Injection tokens
* Can be *types* (class names), *strings* or *symbols*. This depends on how the
* provider with which it is associated was defined. Providers defined with the
* `@Injectable()` decorator use the class name. Custom Providers may use strings
* or symbols as the injection token.
*
* @param token lookup key for the provider to be injected (assigned to the constructor
* parameter).
*
* @see [Providers](https://docs.nestjs.com/providers)
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
*
* @publicApi
*/
function Inject(token) {
const injectCallHasArguments = arguments.length > 0;
return (target, key, index) => {
let type = token || Reflect.getMetadata('design:type', target, key);
// Try to infer the token in a constructor-based injection
if (!type && !injectCallHasArguments) {
type = Reflect.getMetadata(constants_1.PARAMTYPES_METADATA, target, key)?.[index];
}
if (!(0, shared_utils_1.isUndefined)(index)) {
let dependencies = Reflect.getMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, target) || [];
dependencies = [...dependencies, { index, param: type }];
Reflect.defineMetadata(constants_1.SELF_DECLARED_DEPS_METADATA, dependencies, target);
return;
}
let properties = Reflect.getMetadata(constants_1.PROPERTY_DEPS_METADATA, target.constructor) || [];
properties = [...properties, { key, type }];
Reflect.defineMetadata(constants_1.PROPERTY_DEPS_METADATA, properties, target.constructor);
};
}

View File

@@ -0,0 +1,43 @@
import { ScopeOptions } from '../../interfaces/scope-options.interface';
import { Type } from '../../interfaces/type.interface';
/**
* Defines the injection scope.
*
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
*
* @publicApi
*/
export type InjectableOptions = ScopeOptions;
/**
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
* Providers can be injected into other classes via constructor parameter injection
* using Nest's built-in [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection)
* system.
*
* When injecting a provider, it must be visible within the module scope (loosely
* speaking, the containing module) of the class it is being injected into. This
* can be done by:
*
* - defining the provider in the same module scope
* - exporting the provider from one module scope and importing that module into the
* module scope of the class being injected into
* - exporting the provider from a module that is marked as global using the
* `@Global()` decorator
*
* Providers can also be defined in a more explicit and imperative form using
* various [custom provider](https://docs.nestjs.com/fundamentals/custom-providers) techniques that expose
* more capabilities of the DI system.
*
* @param options options specifying scope of injectable
*
* @see [Providers](https://docs.nestjs.com/providers)
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
*
* @publicApi
*/
export declare function Injectable(options?: InjectableOptions): ClassDecorator;
/**
* @publicApi
*/
export declare function mixin<T>(mixinClass: Type<T>): Type<T>;

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Injectable = Injectable;
exports.mixin = mixin;
const uid_1 = require("uid");
const constants_1 = require("../../constants");
/**
* Decorator that marks a class as a [provider](https://docs.nestjs.com/providers).
* Providers can be injected into other classes via constructor parameter injection
* using Nest's built-in [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection)
* system.
*
* When injecting a provider, it must be visible within the module scope (loosely
* speaking, the containing module) of the class it is being injected into. This
* can be done by:
*
* - defining the provider in the same module scope
* - exporting the provider from one module scope and importing that module into the
* module scope of the class being injected into
* - exporting the provider from a module that is marked as global using the
* `@Global()` decorator
*
* Providers can also be defined in a more explicit and imperative form using
* various [custom provider](https://docs.nestjs.com/fundamentals/custom-providers) techniques that expose
* more capabilities of the DI system.
*
* @param options options specifying scope of injectable
*
* @see [Providers](https://docs.nestjs.com/providers)
* @see [Custom Providers](https://docs.nestjs.com/fundamentals/custom-providers)
* @see [Injection Scopes](https://docs.nestjs.com/fundamentals/injection-scopes)
*
* @publicApi
*/
function Injectable(options) {
return (target) => {
Reflect.defineMetadata(constants_1.INJECTABLE_WATERMARK, true, target);
Reflect.defineMetadata(constants_1.SCOPE_OPTIONS_METADATA, options, target);
};
}
/**
* @publicApi
*/
function mixin(mixinClass) {
Object.defineProperty(mixinClass, 'name', {
value: (0, uid_1.uid)(21),
});
Injectable()(mixinClass);
return mixinClass;
}

View File

@@ -0,0 +1,14 @@
/**
* Parameter decorator for an injected dependency marking the
* dependency as optional.
*
* For example:
* ```typescript
* constructor(@Optional() @Inject('HTTP_OPTIONS')private readonly httpClient: T) {}
* ```
*
* @see [Optional providers](https://docs.nestjs.com/providers#optional-providers)
*
* @publicApi
*/
export declare function Optional(): PropertyDecorator & ParameterDecorator;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Optional = Optional;
const constants_1 = require("../../constants");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Parameter decorator for an injected dependency marking the
* dependency as optional.
*
* For example:
* ```typescript
* constructor(@Optional() @Inject('HTTP_OPTIONS')private readonly httpClient: T) {}
* ```
*
* @see [Optional providers](https://docs.nestjs.com/providers#optional-providers)
*
* @publicApi
*/
function Optional() {
return (target, key, index) => {
if (!(0, shared_utils_1.isUndefined)(index)) {
const args = Reflect.getMetadata(constants_1.OPTIONAL_DEPS_METADATA, target) || [];
Reflect.defineMetadata(constants_1.OPTIONAL_DEPS_METADATA, [...args, index], target);
return;
}
const properties = Reflect.getMetadata(constants_1.OPTIONAL_PROPERTY_DEPS_METADATA, target.constructor) || [];
Reflect.defineMetadata(constants_1.OPTIONAL_PROPERTY_DEPS_METADATA, [...properties, key], target.constructor);
};
}

View File

@@ -0,0 +1,20 @@
export type CustomDecorator<TKey = string> = MethodDecorator & ClassDecorator & {
KEY: TKey;
};
/**
* Decorator that assigns metadata to the class/function using the
* specified `key`.
*
* Requires two parameters:
* - `key` - a value defining the key under which the metadata is stored
* - `value` - metadata to be associated with `key`
*
* This metadata can be reflected using the `Reflector` class.
*
* Example: `@SetMetadata('roles', ['admin'])`
*
* @see [Reflection](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata)
*
* @publicApi
*/
export declare const SetMetadata: <K = string, V = any>(metadataKey: K, metadataValue: V) => CustomDecorator<K>;

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetMetadata = void 0;
/**
* Decorator that assigns metadata to the class/function using the
* specified `key`.
*
* Requires two parameters:
* - `key` - a value defining the key under which the metadata is stored
* - `value` - metadata to be associated with `key`
*
* This metadata can be reflected using the `Reflector` class.
*
* Example: `@SetMetadata('roles', ['admin'])`
*
* @see [Reflection](https://docs.nestjs.com/fundamentals/execution-context#reflection-and-metadata)
*
* @publicApi
*/
const SetMetadata = (metadataKey, metadataValue) => {
const decoratorFactory = (target, key, descriptor) => {
if (descriptor) {
Reflect.defineMetadata(metadataKey, metadataValue, descriptor.value);
return descriptor;
}
Reflect.defineMetadata(metadataKey, metadataValue, target);
return target;
};
decoratorFactory.KEY = metadataKey;
return decoratorFactory;
};
exports.SetMetadata = SetMetadata;

View File

@@ -0,0 +1,23 @@
import { CanActivate } from '../../interfaces';
/**
* Decorator that binds guards to the scope of the controller or method,
* depending on its context.
*
* When `@UseGuards` is used at the controller level, the guard will be
* applied to every handler (method) in the controller.
*
* When `@UseGuards` is used at the individual handler level, the guard
* will apply only to that specific method.
*
* @param guards a single guard instance or class, or a list of guard instances
* or classes.
*
* @see [Guards](https://docs.nestjs.com/guards)
*
* @usageNotes
* Guards can also be set up globally for all controllers and routes
* using `app.useGlobalGuards()`. [See here for details](https://docs.nestjs.com/guards#binding-guards)
*
* @publicApi
*/
export declare function UseGuards(...guards: (CanActivate | Function)[]): MethodDecorator & ClassDecorator;

View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UseGuards = UseGuards;
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
/**
* Decorator that binds guards to the scope of the controller or method,
* depending on its context.
*
* When `@UseGuards` is used at the controller level, the guard will be
* applied to every handler (method) in the controller.
*
* When `@UseGuards` is used at the individual handler level, the guard
* will apply only to that specific method.
*
* @param guards a single guard instance or class, or a list of guard instances
* or classes.
*
* @see [Guards](https://docs.nestjs.com/guards)
*
* @usageNotes
* Guards can also be set up globally for all controllers and routes
* using `app.useGlobalGuards()`. [See here for details](https://docs.nestjs.com/guards#binding-guards)
*
* @publicApi
*/
function UseGuards(...guards) {
return (target, key, descriptor) => {
const isGuardValid = (guard) => guard && ((0, shared_utils_1.isFunction)(guard) || (0, shared_utils_1.isFunction)(guard.canActivate));
if (descriptor) {
(0, validate_each_util_1.validateEach)(target.constructor, guards, isGuardValid, '@UseGuards', 'guard');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, descriptor.value);
return descriptor;
}
(0, validate_each_util_1.validateEach)(target, guards, isGuardValid, '@UseGuards', 'guard');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.GUARDS_METADATA, guards, target);
return target;
};
}

View File

@@ -0,0 +1,23 @@
import { NestInterceptor } from '../../interfaces';
/**
* Decorator that binds interceptors to the scope of the controller or method,
* depending on its context.
*
* When `@UseInterceptors` is used at the controller level, the interceptor will
* be applied to every handler (method) in the controller.
*
* When `@UseInterceptors` is used at the individual handler level, the interceptor
* will apply only to that specific method.
*
* @param interceptors a single interceptor instance or class, or a list of
* interceptor instances or classes.
*
* @see [Interceptors](https://docs.nestjs.com/interceptors)
*
* @usageNotes
* Interceptors can also be set up globally for all controllers and routes
* using `app.useGlobalInterceptors()`. [See here for details](https://docs.nestjs.com/interceptors#binding-interceptors)
*
* @publicApi
*/
export declare function UseInterceptors(...interceptors: (NestInterceptor | Function)[]): MethodDecorator & ClassDecorator;

View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UseInterceptors = UseInterceptors;
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
/**
* Decorator that binds interceptors to the scope of the controller or method,
* depending on its context.
*
* When `@UseInterceptors` is used at the controller level, the interceptor will
* be applied to every handler (method) in the controller.
*
* When `@UseInterceptors` is used at the individual handler level, the interceptor
* will apply only to that specific method.
*
* @param interceptors a single interceptor instance or class, or a list of
* interceptor instances or classes.
*
* @see [Interceptors](https://docs.nestjs.com/interceptors)
*
* @usageNotes
* Interceptors can also be set up globally for all controllers and routes
* using `app.useGlobalInterceptors()`. [See here for details](https://docs.nestjs.com/interceptors#binding-interceptors)
*
* @publicApi
*/
function UseInterceptors(...interceptors) {
return (target, key, descriptor) => {
const isInterceptorValid = (interceptor) => interceptor &&
((0, shared_utils_1.isFunction)(interceptor) || (0, shared_utils_1.isFunction)(interceptor.intercept));
if (descriptor) {
(0, validate_each_util_1.validateEach)(target.constructor, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, descriptor.value);
return descriptor;
}
(0, validate_each_util_1.validateEach)(target, interceptors, isInterceptorValid, '@UseInterceptors', 'interceptor');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.INTERCEPTORS_METADATA, interceptors, target);
return target;
};
}

View File

@@ -0,0 +1,23 @@
import { PipeTransform } from '../../interfaces/index';
/**
* Decorator that binds pipes to the scope of the controller or method,
* depending on its context.
*
* When `@UsePipes` is used at the controller level, the pipe will be
* applied to every handler (method) in the controller.
*
* When `@UsePipes` is used at the individual handler level, the pipe
* will apply only to that specific method.
*
* @param pipes a single pipe instance or class, or a list of pipe instances or
* classes.
*
* @see [Pipes](https://docs.nestjs.com/pipes)
*
* @usageNotes
* Pipes can also be set up globally for all controllers and routes
* using `app.useGlobalPipes()`. [See here for details](https://docs.nestjs.com/pipes#class-validator)
*
* @publicApi
*/
export declare function UsePipes(...pipes: (PipeTransform | Function)[]): ClassDecorator & MethodDecorator;

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UsePipes = UsePipes;
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
const validate_each_util_1 = require("../../utils/validate-each.util");
/**
* Decorator that binds pipes to the scope of the controller or method,
* depending on its context.
*
* When `@UsePipes` is used at the controller level, the pipe will be
* applied to every handler (method) in the controller.
*
* When `@UsePipes` is used at the individual handler level, the pipe
* will apply only to that specific method.
*
* @param pipes a single pipe instance or class, or a list of pipe instances or
* classes.
*
* @see [Pipes](https://docs.nestjs.com/pipes)
*
* @usageNotes
* Pipes can also be set up globally for all controllers and routes
* using `app.useGlobalPipes()`. [See here for details](https://docs.nestjs.com/pipes#class-validator)
*
* @publicApi
*/
function UsePipes(...pipes) {
return (target, key, descriptor) => {
const isPipeValid = (pipe) => pipe && ((0, shared_utils_1.isFunction)(pipe) || (0, shared_utils_1.isFunction)(pipe.transform));
if (descriptor) {
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, descriptor.value);
return descriptor;
}
(0, validate_each_util_1.validateEach)(target, pipes, isPipeValid, '@UsePipes', 'pipe');
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.PIPES_METADATA, pipes, target);
return target;
};
}

View File

@@ -0,0 +1,7 @@
import { VersionValue } from '../../interfaces/version-options.interface';
/**
* Sets the version of the endpoint to the passed version
*
* @publicApi
*/
export declare function Version(version: VersionValue): MethodDecorator;

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Version = Version;
const constants_1 = require("../../constants");
/**
* Sets the version of the endpoint to the passed version
*
* @publicApi
*/
function Version(version) {
if (Array.isArray(version)) {
// Drop duplicated versions
version = Array.from(new Set(version));
}
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.VERSION_METADATA, version, descriptor.value);
return descriptor;
};
}

View File

@@ -0,0 +1,13 @@
import { PipeTransform } from '../../index';
import { Type } from '../../interfaces';
import { CustomParamFactory } from '../../interfaces/features/custom-route-param-factory.interface';
export type ParamDecoratorEnhancer = ParameterDecorator;
/**
* Defines HTTP route param decorator
*
* @param factory
* @param enhancers
*
* @publicApi
*/
export declare function createParamDecorator<FactoryData = any, FactoryOutput = any>(factory: CustomParamFactory<FactoryData, FactoryOutput>, enhancers?: ParamDecoratorEnhancer[]): (...dataOrPipes: (Type<PipeTransform> | PipeTransform | FactoryData)[]) => ParameterDecorator;

View File

@@ -0,0 +1,32 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createParamDecorator = createParamDecorator;
const uid_1 = require("uid");
const constants_1 = require("../../constants");
const assign_custom_metadata_util_1 = require("../../utils/assign-custom-metadata.util");
const shared_utils_1 = require("../../utils/shared.utils");
/**
* Defines HTTP route param decorator
*
* @param factory
* @param enhancers
*
* @publicApi
*/
function createParamDecorator(factory, enhancers = []) {
const paramtype = (0, uid_1.uid)(21);
return (data, ...pipes) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) ||
{};
const isPipe = (pipe) => pipe &&
(((0, shared_utils_1.isFunction)(pipe) &&
pipe.prototype &&
(0, shared_utils_1.isFunction)(pipe.prototype.transform)) ||
(0, shared_utils_1.isFunction)(pipe.transform));
const hasParamData = (0, shared_utils_1.isNil)(data) || !isPipe(data);
const paramData = hasParamData ? data : undefined;
const paramPipes = hasParamData ? pipes : [data, ...pipes];
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, (0, assign_custom_metadata_util_1.assignCustomParameterMetadata)(args, paramtype, index, factory, paramData, ...paramPipes), target.constructor, key);
enhancers.forEach(fn => fn(target, key, index));
};
}

View File

@@ -0,0 +1,15 @@
/**
* Request method Decorator. Sets a response header.
*
* For example:
* `@Header('Cache-Control', 'none')`
* `@Header('Cache-Control', () => 'none')`
*
* @param name string to be used for header name
* @param value string to be used for header value
*
* @see [Headers](https://docs.nestjs.com/controllers#headers)
*
* @publicApi
*/
export declare function Header(name: string, value: string | (() => string)): MethodDecorator;

View File

@@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Header = Header;
const constants_1 = require("../../constants");
const extend_metadata_util_1 = require("../../utils/extend-metadata.util");
/**
* Request method Decorator. Sets a response header.
*
* For example:
* `@Header('Cache-Control', 'none')`
* `@Header('Cache-Control', () => 'none')`
*
* @param name string to be used for header name
* @param value string to be used for header value
*
* @see [Headers](https://docs.nestjs.com/controllers#headers)
*
* @publicApi
*/
function Header(name, value) {
return (target, key, descriptor) => {
(0, extend_metadata_util_1.extendArrayMetadata)(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
return descriptor;
};
}

View File

@@ -0,0 +1,11 @@
/**
* Request method Decorator. Defines the HTTP response status code. Overrides
* default status code for the decorated request method.
*
* @param statusCode HTTP response code to be returned by route handler.
*
* @see [Http Status Codes](https://docs.nestjs.com/controllers#status-code)
*
* @publicApi
*/
export declare function HttpCode(statusCode: number): MethodDecorator;

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HttpCode = HttpCode;
const constants_1 = require("../../constants");
/**
* Request method Decorator. Defines the HTTP response status code. Overrides
* default status code for the decorated request method.
*
* @param statusCode HTTP response code to be returned by route handler.
*
* @see [Http Status Codes](https://docs.nestjs.com/controllers#status-code)
*
* @publicApi
*/
function HttpCode(statusCode) {
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.HTTP_CODE_METADATA, statusCode, descriptor.value);
return descriptor;
};
}

View File

@@ -0,0 +1,8 @@
export * from './request-mapping.decorator';
export * from './route-params.decorator';
export * from './http-code.decorator';
export * from './create-route-param-metadata.decorator';
export * from './render.decorator';
export * from './header.decorator';
export * from './redirect.decorator';
export * from './sse.decorator';

11
node_modules/@nestjs/common/decorators/http/index.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./request-mapping.decorator"), exports);
tslib_1.__exportStar(require("./route-params.decorator"), exports);
tslib_1.__exportStar(require("./http-code.decorator"), exports);
tslib_1.__exportStar(require("./create-route-param-metadata.decorator"), exports);
tslib_1.__exportStar(require("./render.decorator"), exports);
tslib_1.__exportStar(require("./header.decorator"), exports);
tslib_1.__exportStar(require("./redirect.decorator"), exports);
tslib_1.__exportStar(require("./sse.decorator"), exports);

View File

@@ -0,0 +1,6 @@
/**
* Redirects request to the specified URL.
*
* @publicApi
*/
export declare function Redirect(url?: string, statusCode?: number): MethodDecorator;

View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Redirect = Redirect;
const constants_1 = require("../../constants");
/**
* Redirects request to the specified URL.
*
* @publicApi
*/
function Redirect(url = '', statusCode) {
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.REDIRECT_METADATA, { statusCode, url }, descriptor.value);
return descriptor;
};
}

View File

@@ -0,0 +1,12 @@
/**
* Route handler method Decorator. Defines a template to be rendered by the controller.
*
* For example: `@Render('index')`
*
* @param template name of the render engine template file
*
* @see [Model-View-Controller](https://docs.nestjs.com/techniques/mvc)
*
* @publicApi
*/
export declare function Render(template: string): MethodDecorator;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Render = Render;
const constants_1 = require("../../constants");
/**
* Route handler method Decorator. Defines a template to be rendered by the controller.
*
* For example: `@Render('index')`
*
* @param template name of the render engine template file
*
* @see [Model-View-Controller](https://docs.nestjs.com/techniques/mvc)
*
* @publicApi
*/
function Render(template) {
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.RENDER_METADATA, template, descriptor.value);
return descriptor;
};
}

View File

@@ -0,0 +1,134 @@
import { RequestMethod } from '../../enums/request-method.enum';
export interface RequestMappingMetadata {
path?: string | string[];
method?: RequestMethod;
}
export declare const RequestMapping: (metadata?: RequestMappingMetadata) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Post: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Get: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Delete: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Put: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Patch: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Options: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Head: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const All: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes HTTP SEARCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Search: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav PROPFIND requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Propfind: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav PROPPATCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Proppatch: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav MKCOL requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Mkcol: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav COPY requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Copy: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav MOVE requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Move: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav LOCK requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Lock: (path?: string | string[]) => MethodDecorator;
/**
* Route handler (method) Decorator. Routes Webdav UNLOCK requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
export declare const Unlock: (path?: string | string[]) => MethodDecorator;

View File

@@ -0,0 +1,154 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
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;
const constants_1 = require("../../constants");
const request_method_enum_1 = require("../../enums/request-method.enum");
const defaultMetadata = {
[constants_1.PATH_METADATA]: '/',
[constants_1.METHOD_METADATA]: request_method_enum_1.RequestMethod.GET,
};
const RequestMapping = (metadata = defaultMetadata) => {
const pathMetadata = metadata[constants_1.PATH_METADATA];
const path = pathMetadata && pathMetadata.length ? pathMetadata : '/';
const requestMethod = metadata[constants_1.METHOD_METADATA] || request_method_enum_1.RequestMethod.GET;
return (target, key, descriptor) => {
Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
Reflect.defineMetadata(constants_1.METHOD_METADATA, requestMethod, descriptor.value);
return descriptor;
};
};
exports.RequestMapping = RequestMapping;
const createMappingDecorator = (method) => (path) => {
return (0, exports.RequestMapping)({
[constants_1.PATH_METADATA]: path,
[constants_1.METHOD_METADATA]: method,
});
};
/**
* Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Post = createMappingDecorator(request_method_enum_1.RequestMethod.POST);
/**
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Get = createMappingDecorator(request_method_enum_1.RequestMethod.GET);
/**
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Delete = createMappingDecorator(request_method_enum_1.RequestMethod.DELETE);
/**
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Put = createMappingDecorator(request_method_enum_1.RequestMethod.PUT);
/**
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Patch = createMappingDecorator(request_method_enum_1.RequestMethod.PATCH);
/**
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Options = createMappingDecorator(request_method_enum_1.RequestMethod.OPTIONS);
/**
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Head = createMappingDecorator(request_method_enum_1.RequestMethod.HEAD);
/**
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.All = createMappingDecorator(request_method_enum_1.RequestMethod.ALL);
/**
* Route handler (method) Decorator. Routes HTTP SEARCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Search = createMappingDecorator(request_method_enum_1.RequestMethod.SEARCH);
/**
* Route handler (method) Decorator. Routes Webdav PROPFIND requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Propfind = createMappingDecorator(request_method_enum_1.RequestMethod.PROPFIND);
/**
* Route handler (method) Decorator. Routes Webdav PROPPATCH requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Proppatch = createMappingDecorator(request_method_enum_1.RequestMethod.PROPPATCH);
/**
* Route handler (method) Decorator. Routes Webdav MKCOL requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Mkcol = createMappingDecorator(request_method_enum_1.RequestMethod.MKCOL);
/**
* Route handler (method) Decorator. Routes Webdav COPY requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Copy = createMappingDecorator(request_method_enum_1.RequestMethod.COPY);
/**
* Route handler (method) Decorator. Routes Webdav MOVE requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Move = createMappingDecorator(request_method_enum_1.RequestMethod.MOVE);
/**
* Route handler (method) Decorator. Routes Webdav LOCK requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Lock = createMappingDecorator(request_method_enum_1.RequestMethod.LOCK);
/**
* Route handler (method) Decorator. Routes Webdav UNLOCK requests to the specified path.
*
* @see [Routing](https://docs.nestjs.com/controllers#routing)
*
* @publicApi
*/
exports.Unlock = createMappingDecorator(request_method_enum_1.RequestMethod.UNLOCK);

View File

@@ -0,0 +1,445 @@
import { PipeTransform } from '../../index';
import { Type } from '../../interfaces';
/**
* The `@Response()`/`@Res` parameter decorator options.
*/
export interface ResponseDecoratorOptions {
/**
* Determines whether the response will be sent manually within the route handler,
* with the use of native response handling methods exposed by the platform-specific response object,
* or if it should passthrough Nest response processing pipeline.
*
* @default false
*/
passthrough: boolean;
}
export type ParamData = object | string | number;
export interface RouteParamMetadata {
index: number;
data?: ParamData;
}
export declare function assignMetadata<TParamtype = any, TArgs = any>(args: TArgs, paramtype: TParamtype, index: number, data?: ParamData, ...pipes: (Type<PipeTransform> | PipeTransform)[]): TArgs & {
[x: string]: {
index: number;
data: ParamData | undefined;
pipes: (PipeTransform<any, any> | Type<PipeTransform<any, any>>)[];
};
};
/**
* Route handler parameter decorator. Extracts the `Request`
* object from the underlying platform and populates the decorated
* parameter with the value of `Request`.
*
* Example: `logout(@Request() req)`
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare const Request: () => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `Response`
* object from the underlying platform and populates the decorated
* parameter with the value of `Response`.
*
* Example: `logout(@Response() res)`
*
* @publicApi
*/
export declare const Response: (options?: ResponseDecoratorOptions) => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts reference to the `Next` function
* from the underlying platform and populates the decorated
* parameter with the value of `Next`.
*
* @publicApi
*/
export declare const Next: () => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `Ip` property
* from the `req` object and populates the decorated
* parameter with the value of `ip`.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare const Ip: () => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `Session` object
* from the underlying platform and populates the decorated
* parameter with the value of `Session`.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare const Session: () => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `file` object
* and populates the decorated parameter with the value of `file`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFile() file) {
* console.log(file);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
export declare function UploadedFile(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `file` object
* and populates the decorated parameter with the value of `file`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFile() file) {
* console.log(file);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
export declare function UploadedFile(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `file` object
* and populates the decorated parameter with the value of `file`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFile() file) {
* console.log(file);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
export declare function UploadedFile(fileKey?: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `files` object
* and populates the decorated parameter with the value of `files`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFiles() files) {
* console.log(files);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
export declare function UploadedFiles(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `files` object
* and populates the decorated parameter with the value of `files`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFiles() files) {
* console.log(files);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
export declare function UploadedFiles(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `headers`
* property from the `req` object and populates the decorated
* parameter with the value of `headers`.
*
* For example: `async update(@Headers('Cache-Control') cacheControl: string)`
*
* @param property name of single header property to extract.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare const Headers: (property?: string) => ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `query`
* property from the `req` object and populates the decorated
* parameter with the value of `query`. May also apply pipes to the bound
* query parameter.
*
* For example:
* ```typescript
* async find(@Query('user') user: string)
* ```
*
* @param property name of single property to extract from the `query` object
* @param pipes one or more pipes to apply to the bound query parameter
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function Query(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `query`
* property from the `req` object and populates the decorated
* parameter with the value of `query`. May also apply pipes to the bound
* query parameter.
*
* For example:
* ```typescript
* async find(@Query('user') user: string)
* ```
*
* @param property name of single property to extract from the `query` object
* @param pipes one or more pipes to apply to the bound query parameter
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function Query(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `query`
* property from the `req` object and populates the decorated
* parameter with the value of `query`. May also apply pipes to the bound
* query parameter.
*
* For example:
* ```typescript
* async find(@Query('user') user: string)
* ```
*
* @param property name of single property to extract from the `query` object
* @param pipes one or more pipes to apply to the bound query parameter
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function Query(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the entire `body`
* object from the `req` object and populates the decorated
* parameter with the value of `body`.
*
* For example:
* ```typescript
* async create(@Body() createDto: CreateCatDto)
* ```
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function Body(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the entire `body`
* object from the `req` object and populates the decorated
* parameter with the value of `body`. Also applies the specified
* pipes to that parameter.
*
* For example:
* ```typescript
* async create(@Body(new ValidationPipe()) createDto: CreateCatDto)
* ```
*
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound body parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function Body(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts a single property from
* the `body` object property of the `req` object and populates the decorated
* parameter with the value of that property. Also applies pipes to the bound
* body parameter.
*
* For example:
* ```typescript
* async create(@Body('role', new ValidationPipe()) role: string)
* ```
*
* @param property name of single property to extract from the `body` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound body parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function Body(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `rawBody` Buffer
* property from the `req` object and populates the decorated parameter with that value.
*
* For example:
* ```typescript
* async create(@RawBody() rawBody: Buffer | undefined)
* ```
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
*
* @publicApi
*/
export declare function RawBody(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `rawBody` Buffer
* property from the `req` object and populates the decorated parameter with that value.
* Also applies pipes to the bound rawBody parameter.
*
* For example:
* ```typescript
* async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
* ```
*
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound body parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function RawBody(...pipes: (Type<PipeTransform<Buffer | undefined>> | PipeTransform<Buffer | undefined>)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `params`
* property from the `req` object and populates the decorated
* parameter with the value of `params`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@Param() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@Param('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function Param(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `params`
* property from the `req` object and populates the decorated
* parameter with the value of `params`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@Param() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@Param('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function Param(...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `params`
* property from the `req` object and populates the decorated
* parameter with the value of `params`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@Param() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@Param('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
export declare function Param(property: string, ...pipes: (Type<PipeTransform> | PipeTransform)[]): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `hosts`
* property from the `req` object and populates the decorated
* parameter with the value of `hosts`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@HostParam() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@HostParam('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function HostParam(): ParameterDecorator;
/**
* Route handler parameter decorator. Extracts the `hosts`
* property from the `req` object and populates the decorated
* parameter with the value of `hosts`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@HostParam() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@HostParam('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
export declare function HostParam(property: string): ParameterDecorator;
export declare const Req: () => ParameterDecorator;
export declare const Res: (options?: ResponseDecoratorOptions) => ParameterDecorator;

View File

@@ -0,0 +1,265 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Res = exports.Req = exports.Headers = exports.Session = exports.Ip = exports.Next = exports.Response = exports.Request = void 0;
exports.assignMetadata = assignMetadata;
exports.UploadedFile = UploadedFile;
exports.UploadedFiles = UploadedFiles;
exports.Query = Query;
exports.Body = Body;
exports.RawBody = RawBody;
exports.Param = Param;
exports.HostParam = HostParam;
const constants_1 = require("../../constants");
const route_paramtypes_enum_1 = require("../../enums/route-paramtypes.enum");
const shared_utils_1 = require("../../utils/shared.utils");
function assignMetadata(args, paramtype, index, data, ...pipes) {
return {
...args,
[`${paramtype}:${index}`]: {
index,
data,
pipes,
},
};
}
function createRouteParamDecorator(paramtype) {
return (data) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) ||
{};
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, data), target.constructor, key);
};
}
const createPipesRouteParamDecorator = (paramtype) => (data, ...pipes) => (target, key, index) => {
const args = Reflect.getMetadata(constants_1.ROUTE_ARGS_METADATA, target.constructor, key) || {};
const hasParamData = (0, shared_utils_1.isNil)(data) || (0, shared_utils_1.isString)(data);
const paramData = hasParamData ? data : undefined;
const paramPipes = hasParamData ? pipes : [data, ...pipes];
Reflect.defineMetadata(constants_1.ROUTE_ARGS_METADATA, assignMetadata(args, paramtype, index, paramData, ...paramPipes), target.constructor, key);
};
/**
* Route handler parameter decorator. Extracts the `Request`
* object from the underlying platform and populates the decorated
* parameter with the value of `Request`.
*
* Example: `logout(@Request() req)`
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
exports.Request = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.REQUEST);
/**
* Route handler parameter decorator. Extracts the `Response`
* object from the underlying platform and populates the decorated
* parameter with the value of `Response`.
*
* Example: `logout(@Response() res)`
*
* @publicApi
*/
const Response = (options) => (target, key, index) => {
if (options?.passthrough) {
Reflect.defineMetadata(constants_1.RESPONSE_PASSTHROUGH_METADATA, options?.passthrough, target.constructor, key);
}
return createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RESPONSE)()(target, key, index);
};
exports.Response = Response;
/**
* Route handler parameter decorator. Extracts reference to the `Next` function
* from the underlying platform and populates the decorated
* parameter with the value of `Next`.
*
* @publicApi
*/
exports.Next = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.NEXT);
/**
* Route handler parameter decorator. Extracts the `Ip` property
* from the `req` object and populates the decorated
* parameter with the value of `ip`.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
exports.Ip = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.IP);
/**
* Route handler parameter decorator. Extracts the `Session` object
* from the underlying platform and populates the decorated
* parameter with the value of `Session`.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
exports.Session = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.SESSION);
/**
* Route handler parameter decorator. Extracts the `file` object
* and populates the decorated parameter with the value of `file`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFile() file) {
* console.log(file);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
function UploadedFile(fileKey, ...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILE)(fileKey, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the `files` object
* and populates the decorated parameter with the value of `files`.
* Used in conjunction with
* [multer middleware](https://github.com/expressjs/multer) for Express-based applications.
*
* For example:
* ```typescript
* uploadFile(@UploadedFiles() files) {
* console.log(files);
* }
* ```
* @see [Request object](https://docs.nestjs.com/techniques/file-upload)
*
* @publicApi
*/
function UploadedFiles(...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.FILES)(undefined, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the `headers`
* property from the `req` object and populates the decorated
* parameter with the value of `headers`.
*
* For example: `async update(@Headers('Cache-Control') cacheControl: string)`
*
* @param property name of single header property to extract.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
exports.Headers = createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.HEADERS);
/**
* Route handler parameter decorator. Extracts the `query`
* property from the `req` object and populates the decorated
* parameter with the value of `query`. May also apply pipes to the bound
* query parameter.
*
* For example:
* ```typescript
* async find(@Query('user') user: string)
* ```
*
* @param property name of single property to extract from the `query` object
* @param pipes one or more pipes to apply to the bound query parameter
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
function Query(property, ...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.QUERY)(property, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the entire `body` object
* property, or optionally a named property of the `body` object, from
* the `req` object and populates the decorated parameter with that value.
* Also applies pipes to the bound body parameter.
*
* For example:
* ```typescript
* async create(@Body('role', new ValidationPipe()) role: string)
* ```
*
* @param property name of single property to extract from the `body` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound body parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
function Body(property, ...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.BODY)(property, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the `rawBody` Buffer
* property from the `req` object and populates the decorated parameter with that value.
* Also applies pipes to the bound rawBody parameter.
*
* For example:
* ```typescript
* async create(@RawBody(new ValidationPipe()) rawBody: Buffer)
* ```
*
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound body parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Raw body](https://docs.nestjs.com/faq/raw-body)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
function RawBody(...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.RAW_BODY)(undefined, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the `params`
* property from the `req` object and populates the decorated
* parameter with the value of `params`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@Param() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@Param('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
* @param pipes one or more pipes - either instances or classes - to apply to
* the bound parameter.
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
* @see [Working with pipes](https://docs.nestjs.com/custom-decorators#working-with-pipes)
*
* @publicApi
*/
function Param(property, ...pipes) {
return createPipesRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.PARAM)(property, ...pipes);
}
/**
* Route handler parameter decorator. Extracts the `hosts`
* property from the `req` object and populates the decorated
* parameter with the value of `params`. May also apply pipes to the bound
* parameter.
*
* For example, extracting all params:
* ```typescript
* findOne(@HostParam() params: string[])
* ```
*
* For example, extracting a single param:
* ```typescript
* findOne(@HostParam('id') id: string)
* ```
* @param property name of single property to extract from the `req` object
*
* @see [Request object](https://docs.nestjs.com/controllers#request-object)
*
* @publicApi
*/
function HostParam(property) {
return createRouteParamDecorator(route_paramtypes_enum_1.RouteParamtypes.HOST)(property);
}
exports.Req = exports.Request;
exports.Res = exports.Response;

View File

@@ -0,0 +1,10 @@
import { METHOD_METADATA } from '../../constants';
import { RequestMethod } from '../../enums/request-method.enum';
/**
* Declares this route as a Server-Sent-Events endpoint
*
* @publicApi
*/
export declare function Sse(path?: string, options?: {
[METHOD_METADATA]?: RequestMethod;
}): MethodDecorator;

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sse = Sse;
const constants_1 = require("../../constants");
const request_method_enum_1 = require("../../enums/request-method.enum");
/**
* Declares this route as a Server-Sent-Events endpoint
*
* @publicApi
*/
function Sse(path, options = {
[constants_1.METHOD_METADATA]: request_method_enum_1.RequestMethod.GET,
}) {
return (target, key, descriptor) => {
path = path && path.length ? path : '/';
Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
Reflect.defineMetadata(constants_1.METHOD_METADATA, options[constants_1.METHOD_METADATA], descriptor.value);
Reflect.defineMetadata(constants_1.SSE_METADATA, true, descriptor.value);
return descriptor;
};
}

3
node_modules/@nestjs/common/decorators/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export * from './core';
export * from './modules';
export * from './http';

6
node_modules/@nestjs/common/decorators/index.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./core"), exports);
tslib_1.__exportStar(require("./modules"), exports);
tslib_1.__exportStar(require("./http"), exports);

View File

@@ -0,0 +1,12 @@
/**
* Decorator that makes a module global-scoped.
*
* Once imported into any module, a global-scoped module will be visible
* in all modules. Thereafter, modules that wish to inject a service exported
* from a global module do not need to import the provider module.
*
* @see [Global modules](https://docs.nestjs.com/modules#global-modules)
*
* @publicApi
*/
export declare function Global(): ClassDecorator;

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Global = Global;
const constants_1 = require("../../constants");
/**
* Decorator that makes a module global-scoped.
*
* Once imported into any module, a global-scoped module will be visible
* in all modules. Thereafter, modules that wish to inject a service exported
* from a global module do not need to import the provider module.
*
* @see [Global modules](https://docs.nestjs.com/modules#global-modules)
*
* @publicApi
*/
function Global() {
return (target) => {
Reflect.defineMetadata(constants_1.GLOBAL_MODULE_METADATA, true, target);
};
}

View File

@@ -0,0 +1,2 @@
export * from './global.decorator';
export * from './module.decorator';

View File

@@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
tslib_1.__exportStar(require("./global.decorator"), exports);
tslib_1.__exportStar(require("./module.decorator"), exports);

View File

@@ -0,0 +1,16 @@
import { ModuleMetadata } from '../../interfaces/modules/module-metadata.interface';
/**
* Decorator that marks a class as a [module](https://docs.nestjs.com/modules).
*
* Modules are used by Nest to organize the application structure into scopes. Controllers
* and Providers are scoped by the module they are declared in. Modules and their
* classes (Controllers and Providers) form a graph that determines how Nest
* performs [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
*
* @param metadata module configuration metadata
*
* @see [Modules](https://docs.nestjs.com/modules)
*
* @publicApi
*/
export declare function Module(metadata: ModuleMetadata): ClassDecorator;

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = Module;
const validate_module_keys_util_1 = require("../../utils/validate-module-keys.util");
/**
* Decorator that marks a class as a [module](https://docs.nestjs.com/modules).
*
* Modules are used by Nest to organize the application structure into scopes. Controllers
* and Providers are scoped by the module they are declared in. Modules and their
* classes (Controllers and Providers) form a graph that determines how Nest
* performs [Dependency Injection (DI)](https://docs.nestjs.com/providers#dependency-injection).
*
* @param metadata module configuration metadata
*
* @see [Modules](https://docs.nestjs.com/modules)
*
* @publicApi
*/
function Module(metadata) {
const propsKeys = Object.keys(metadata);
(0, validate_module_keys_util_1.validateModuleKeys)(propsKeys);
return (target) => {
for (const property in metadata) {
if (Object.hasOwnProperty.call(metadata, property)) {
Reflect.defineMetadata(property, metadata[property], target);
}
}
};
}