• Parameters

    • req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>
    • res: Response<any, Record<string, any>, number>
    • next: NextFunction

    Returns void

Properties

all: IRouterMatcher<Router, "all">

Special-cased "all" method, applying the given route path, middleware, and callback to every HTTP method.

checkout: IRouterMatcher<Router, any>
connect: IRouterMatcher<Router, any>
copy: IRouterMatcher<Router, any>
delete: IRouterMatcher<Router, "delete">
get: IRouterMatcher<Router, "get">
head: IRouterMatcher<Router, "head">
link: IRouterMatcher<Router, any>
lock: IRouterMatcher<Router, any>
"m-search": IRouterMatcher<Router, any>
merge: IRouterMatcher<Router, any>
mkactivity: IRouterMatcher<Router, any>
mkcol: IRouterMatcher<Router, any>
move: IRouterMatcher<Router, any>
notify: IRouterMatcher<Router, any>
options: IRouterMatcher<Router, "options">
patch: IRouterMatcher<Router, "patch">
post: IRouterMatcher<Router, "post">
propfind: IRouterMatcher<Router, any>
proppatch: IRouterMatcher<Router, any>
purge: IRouterMatcher<Router, any>
put: IRouterMatcher<Router, "put">
report: IRouterMatcher<Router, any>
search: IRouterMatcher<Router, any>
stack: ILayer[]

Stack of configured routes

subscribe: IRouterMatcher<Router, any>
trace: IRouterMatcher<Router, any>
unlink: IRouterMatcher<Router, any>
unlock: IRouterMatcher<Router, any>
unsubscribe: IRouterMatcher<Router, any>
use: IRouterHandler<Router, string> & IRouterMatcher<Router, any>

Methods

  • Map the given param placeholder name(s) to the given callback(s).

    Parameter mapping is used to provide pre-conditions to routes which use normalized placeholders. For example a :user_id parameter could automatically load a user's information from the database without any additional code,

    The callback uses the samesignature as middleware, the only differencing being that the value of the placeholder is passed, in this case the id of the user. Once the next() function is invoked, just like middleware it will continue on to execute the route, or subsequent parameter functions.

     app.param('user_id', function(req, res, next, id){
       User.find(id, function(err, user){
         if (err) {
           next(err);
         } else if (user) {
           req.user = user;
           next();
         } else {
           next(new Error('failed to load user'));
         }
       });
     });
    

    Parameters

    • name: string
    • handler: RequestParamHandler

    Returns this

  • Alternatively, you can pass only a callback, in which case you have the opportunity to alter the app.param()

    Parameters

    • callback: (name: string, matcher: RegExp) => RequestParamHandler

    Returns this

    since version 4.11

  • Type Parameters

    • T extends string

    Parameters

    • prefix: T

    Returns IRoute<T>

  • Parameters

    • prefix: PathParams

    Returns IRoute<string>