@tsed/common
Version:
A TypeScript Framework on top of Express
82 lines (81 loc) • 2.62 kB
TypeScript
import { Type } from "@tsed/core";
import { IParamOptions } from "../../interfaces/IParamOptions";
/**
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
*
* #### Example
*
* ```typescript
* @Controller('/')
* class MyCtrl {
* @Post('/')
* create(@Cookies() cookies: any) {
* console.log('Entire cookies', cookies);
* }
*
* @Post('/')
* create(@Cookies('id') id: string) {
* console.log('ID', id);
* }
*
* @Post('/')
* create(@Cookies('user') user: IUser) {
* console.log('user', user);
* }
* }
* ```
* > For more information on deserialization see [converters](/docs/converters.md) page.
*
* @param expression The path of the property to get.
* @param useType The type of the class that to be used to deserialize the data.
* @decorator
* @operation
* @input
*/
export declare function CookiesParams(expression: string | any, useType: any): ParameterDecorator;
export declare function CookiesParams(): ParameterDecorator;
export declare function CookiesParams(expression: string | any): ParameterDecorator;
export declare function CookiesParams(options: IParamOptions<any>): ParameterDecorator;
/**
* Cookies or CookiesParams return the value from [request.cookies](http://expressjs.com/en/4x/api.html#req.cookies) object.
*
* #### Example
*
* ```typescript
* @Controller('/')
* class MyCtrl {
* @Post('/')
* create(@Cookies() body: any) {
* console.log('Entire body', body);
* }
*
* @Post('/')
* create(@Cookies('id') id: string) {
* console.log('ID', id);
* }
*
* @Post('/')
* create(@Cookies('user') user: User) { // with deserialization
* console.log('user', user);
* }
*
* @Post('/')
* create(@Cookies('users', User) users: User[]) { // with deserialization
* console.log('users', users);
* }
* }
* ```
* > For more information on deserialization see [converters](/docs/converters.md) page.
*
* @param expression The path of the property to get.
* @param useType The type of the class that to be used to deserialize the data.
* @decorator
* @aliasof CookiesParams
* @operation
* @input
*/
export declare function Cookies(expression: string, useType: Type<any>): ParameterDecorator;
export declare function Cookies(expression: string): ParameterDecorator;
export declare function Cookies(useType: Type<any>): ParameterDecorator;
export declare function Cookies(options: IParamOptions<any>): ParameterDecorator;
export declare function Cookies(): ParameterDecorator;