Preparing search index...

    Interface PluginRouter

    The router passed to Plugin.registerWithRouter: a standard Express router where routes registered directly require admin authentication, plus access for opening individual routes up to readwrite or readonly users:

    router.access('readonly').get('/data/:id', handler)
    

    The reserved paths / and /config cannot be downgraded.

    interface PluginRouter {
        all: IRouterMatcher<PluginRouter, "all">;
        checkout: IRouterMatcher<PluginRouter>;
        connect: IRouterMatcher<PluginRouter>;
        copy: IRouterMatcher<PluginRouter>;
        delete: IRouterMatcher<PluginRouter, "delete">;
        get: IRouterMatcher<PluginRouter, "get">;
        head: IRouterMatcher<PluginRouter, "head">;
        link: IRouterMatcher<PluginRouter>;
        lock: IRouterMatcher<PluginRouter>;
        "m-search": IRouterMatcher<PluginRouter>;
        merge: IRouterMatcher<PluginRouter>;
        mkactivity: IRouterMatcher<PluginRouter>;
        mkcol: IRouterMatcher<PluginRouter>;
        move: IRouterMatcher<PluginRouter>;
        notify: IRouterMatcher<PluginRouter>;
        options: IRouterMatcher<PluginRouter, "options">;
        patch: IRouterMatcher<PluginRouter, "patch">;
        post: IRouterMatcher<PluginRouter, "post">;
        propfind: IRouterMatcher<PluginRouter>;
        proppatch: IRouterMatcher<PluginRouter>;
        purge: IRouterMatcher<PluginRouter>;
        put: IRouterMatcher<PluginRouter, "put">;
        report: IRouterMatcher<PluginRouter>;
        search: IRouterMatcher<PluginRouter>;
        stack: ILayer[];
        subscribe: IRouterMatcher<PluginRouter>;
        trace: IRouterMatcher<PluginRouter>;
        unlink: IRouterMatcher<PluginRouter>;
        unlock: IRouterMatcher<PluginRouter>;
        unsubscribe: IRouterMatcher<PluginRouter>;
        use: IRouterHandler<PluginRouter, string> & IRouterMatcher<
            PluginRouter,
            any,
        >;
        query?: IRouterMatcher<PluginRouter, "query">;
        access(level: RouteAccessLevel): AccessScopedRouter;
        param(name: string, handler: RequestParamHandler): this;
        param(
            callback: (name: string, matcher: RegExp) => RequestParamHandler,
        ): this;
        route<T extends string>(prefix: T): IRoute<T>;
        route(prefix: PathParams): IRoute;
        (
            req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>,
            res: Response<any, Record<string, any>>,
            next: NextFunction,
        ): void;
    }

    Hierarchy

    • IRouter
      • PluginRouter
    • Parameters

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

      Returns void

    Index
    all: IRouterMatcher<PluginRouter, "all">

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

    checkout: IRouterMatcher<PluginRouter>
    connect: IRouterMatcher<PluginRouter>
    copy: IRouterMatcher<PluginRouter>
    delete: IRouterMatcher<PluginRouter, "delete">
    get: IRouterMatcher<PluginRouter, "get">
    head: IRouterMatcher<PluginRouter, "head">
    link: IRouterMatcher<PluginRouter>
    lock: IRouterMatcher<PluginRouter>
    "m-search": IRouterMatcher<PluginRouter>
    merge: IRouterMatcher<PluginRouter>
    mkactivity: IRouterMatcher<PluginRouter>
    mkcol: IRouterMatcher<PluginRouter>
    move: IRouterMatcher<PluginRouter>
    notify: IRouterMatcher<PluginRouter>
    options: IRouterMatcher<PluginRouter, "options">
    patch: IRouterMatcher<PluginRouter, "patch">

    post

    post: IRouterMatcher<PluginRouter, "post">
    propfind: IRouterMatcher<PluginRouter>
    proppatch: IRouterMatcher<PluginRouter>
    purge: IRouterMatcher<PluginRouter>
    put: IRouterMatcher<PluginRouter, "put">
    report: IRouterMatcher<PluginRouter>
    search: IRouterMatcher<PluginRouter>
    stack: ILayer[]

    Stack of configured routes

    subscribe: IRouterMatcher<PluginRouter>
    trace: IRouterMatcher<PluginRouter>
    unlink: IRouterMatcher<PluginRouter>
    unlock: IRouterMatcher<PluginRouter>
    unsubscribe: IRouterMatcher<PluginRouter>
    use: IRouterHandler<PluginRouter, string> & IRouterMatcher<PluginRouter, any>
    query?: IRouterMatcher<PluginRouter, "query">

    Requires Node.js >=20.19.3 <21 || >=22.2.0

    • 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