@tsed/common
Version:
A TypeScript Framework on top of Express
37 lines (36 loc) • 1.14 kB
TypeScript
import { IParamOptions } from "../../interfaces/IParamOptions";
/**
* Session return the value from [request.session](http://expressjs.com/en/4x/api.html#req.session) object.
*
* #### Example
*
* ```typescript
* @Controller('/')
* class MyCtrl {
* @Post('/')
* create(@Session() session: Express.Session) {
* console.log('Entire session', session);
* }
*
* @Post('/')
* create(@Session('id') id: string) {
* console.log('ID', id);
* }
*
* @Post('/') // Example to deserialize use from session
* create(@Session({expression: 'user', useConverter: true}) user: User) {
* console.log('user', user);
* console.log('instanceOf user', user instanceof User);
* }
* }
* ```
* > For more information on deserialization see [converters](/docs/converters.md) page.
*
* @param expression The path of the property to get.
* @decorator
* @operation
* @input
*/
export declare function Session(expression: string): ParameterDecorator;
export declare function Session(options: IParamOptions<any>): ParameterDecorator;
export declare function Session(): ParameterDecorator;