/// import { Request } from 'express'; export declare abstract class AbstractParam { resolve: (options: T, req: Request) => any; parse?: (arg: any, options: T, req: Request) => any; validate?: (arg: any, options: T, req: Request) => boolean; required?: boolean; paramName?: string; type?: any; } export interface ParamOptions { type?: any; parse?: (arg: any, options: T, req: Request) => any; validate?: (arg: any, options: T, req: Request) => boolean; required?: boolean; } export interface ParamsOptions { parse?: (arg: any, options: T, req: Request) => any; validate?: (arg: any, options: T, req: Request) => boolean; } export declare function parse(value: any, metadata: AbstractParam): any; /** * Type of QueryParam decorator */ export interface QueryParamDecorator { /** * Injects a query parameter into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@QueryParam('param') param : string) { * // param is "foobar" for url "/?param=foobar" * } * } * ``` */ (paramName: string, options?: ParamOptions): any; new (paramName: string, options?: ParamOptions): QueryParam; } /** * Type of QueryParam metadata * @see {@link QueryParamDecorator} */ export interface QueryParam extends AbstractParam, ParamOptions { paramName: string; } export declare const QueryParam: QueryParamDecorator; /** * Type of QueryParams decorator */ export interface QueryParamsDecorator { /** * Injects all query parameters as object into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@QueryParams() params : object) { * // params is `{ param: "foobar" }` for url "/?param=foobar" * } * } * ``` */ (options?: ParamsOptions): any; new (options?: ParamsOptions): QueryParams; } /** * Type of QueryParams metadata * @see {@link QueryParamsDecorator} */ export interface QueryParams extends AbstractParam, ParamsOptions { } export declare const QueryParams: QueryParamsDecorator; /** * Type of Param decorator */ export interface ParamDecorator { /** * Injects a path parameter into controller handler * @example * ``` * * class ExampleController { * @Get('/:id') * index(@Param('id') id : string) { * // id is "foobar" for url "/foobar" * } * } * ``` */ (paramName: string, options?: ParamOptions): any; new (paramName: string, options?: ParamOptions): Param; } /** * Type of the Param metadata * @see {@link ParamDecorator} */ export interface Param extends AbstractParam, ParamOptions { paramName: string; } export declare const Param: ParamDecorator; export interface ParamsDecorator { /** * Injects all path parameters as object into controller handler * @example * ``` * * class ExampleController { * @Get('/:arg0/:arg1') * index(@Params() params : object) { * // params is `{ arg0: "foo", arg1: "bar" }` for url "/foo/bar" * } * } * ``` */ (options?: ParamsOptions): any; new (options?: ParamsOptions): Params; } /** * Type of the Params metadata * @see {@link ParamsDecorator} */ export interface Params extends AbstractParam, ParamsOptions { } export declare const Params: ParamsDecorator; /** * Type of the BodyParam decorator */ export interface BodyParamDecorator { /** * Injects a body parameter into controller handler * Requires an express body-parser * @example * ``` * * class ExampleController { * @Post('/') * index(@BodyParam('id') id : string) { * // id is "foobar" for post body '{"id":"foobar"}' * } * } * ``` */ (paramName: string, options?: ParamOptions): any; new (paramName: string, options?: ParamOptions): BodyParam; } /** * Type of the BodyParam metadata * @see {@link BodyParamDecorator} */ export interface BodyParam extends AbstractParam, ParamOptions { paramName: string; } export declare const BodyParam: BodyParamDecorator; export interface BodyOptions { parse?: (arg: { [key: string]: string; } | Buffer | string | any, options: Body, req: Request) => any; } /** * Type of the Body decorator */ export interface BodyDecorator { /** * Injects the complete body as object, string or Buffer depends on the body-parser middleware * Requires an express body-parser * @example * ``` * * class ExampleController { * @Post('/:arg0/:arg1') * index(@Body() params : object) { * // params is `{ id: "foobar" }` for post body "{"id":"foobar"}" * } * } * ``` */ (options?: BodyOptions): any; new (options?: BodyOptions): Body; } /** * Type of the Body metadata * @see {@link BodyDecorator} */ export interface Body extends AbstractParam, BodyOptions { } export declare const Body: BodyDecorator; /** * Type of the HeaderParam decorator */ export interface HeaderParamDecorator { /** * Injects a header parameter into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@HeaderParam('if-none-match') etag: string) { * // etag contains the given 'If-None-Match' header * } * } * ``` */ (headerName: string, options?: ParamOptions): any; new (headerName: string, options?: ParamOptions): HeaderParam; } /** * Type of the HeaderParam metadata * @see {@link HeaderParamDecorator} */ export interface HeaderParam extends AbstractParam, ParamOptions { headerName: string; } export declare const HeaderParam: HeaderParamDecorator; /** * Type of the Headers decorator */ export interface HeadersDecorator { /** * Injects all header parameters as object into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@Headers() headers: IncomingHttpHeaders) { * // headers contains all request headers * } * } * ``` */ (options?: ParamOptions): any; new (options?: ParamOptions): Headers; } /** * Type of the Headers metadata * @see {@link HeadersDecorator} */ export interface Headers extends AbstractParam, ParamsOptions { } export declare const Headers: HeadersDecorator; /** * Type of the SessionParam decorator */ export interface SessionParamDecorator { /** * Injects a session parameter into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@SessionParam('foobar') foobar: string) { * } * } * ``` */ (paramName: string, options?: ParamOptions): any; new (paramName: string, options?: ParamOptions): SessionParam; } /** * Type of the SessionParam metadata * @see {@link SessionParamDecorator} */ export interface SessionParam extends AbstractParam, ParamOptions { paramName: string; } export declare const SessionParam: SessionParamDecorator; /** * Type of the Session decorator */ export interface SessionDecorator { /** * Injects the session object into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@Session() session: Express.Session) { * } * } * ``` */ (options?: ParamOptions): any; new (options?: ParamOptions): Session; } /** * Type of the Session metadata * @see {@link SessionDecorator} */ export interface Session extends AbstractParam, ParamsOptions { } export declare const Session: SessionDecorator; /** * Type of the SessionId decorator */ export interface SessionIdDecorator { /** * Injects the session id into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@SessionId() sessId: string) { * } * } * ``` */ (): any; new (): Session; } /** * Type of the SessionId metadata * @see {@link SessionIdDecorator} */ export interface SessionId extends AbstractParam { } export declare const SessionId: SessionIdDecorator; /** * Type of the Req decorator */ export interface ReqDecorator { /** * Injects the express request object into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@Req() req : Express.Request) { * } * } * ``` */ (): any; new (): Req; } /** * Type of the Req metadata * @see {@link ReqDecorator} */ export interface Req extends AbstractParam { } export declare const Req: ReqDecorator; /** * Type of the Res decorator */ export interface ResDecorator { /** * Injects the express response object into controller handler * @example * ``` * * class ExampleController { * @Get('/') * index(@Res() res : Express.Response) { * } * } * ``` */ (): any; new (): Res; } /** * Type of the Res metadata * @see {@link ResDecorator} */ export interface Res extends AbstractParam { } export declare const Res: ResDecorator; /** * Type of the Err decorator */ export interface ErrDecorator { /** * Injects the optional error from a middleware into controller handler * @example * ``` * * class ExampleController { * @Post('/login') * @Use((_req, _res, next) => next(Math.random() < .5 ? new Error('err') : null)) * index(@Err() err : any, @Res() res : Express.Response) { * } * } * ``` */ (): any; new (): Err; } /** * Type of the Res metadata * @see {@link ResDecorator} */ export interface Err extends AbstractParam { } export declare const Err: ErrDecorator;