Trilium Backend API
    Preparing search index...

    Interface Router

    interface Router {
        all: IRouterMatcher<Router, "all">;
        checkout: IRouterMatcher<Router>;
        connect: IRouterMatcher<Router>;
        copy: IRouterMatcher<Router>;
        delete: IRouterMatcher<Router, "delete">;
        get: IRouterMatcher<Router, "get">;
        head: IRouterMatcher<Router, "head">;
        link: IRouterMatcher<Router>;
        lock: IRouterMatcher<Router>;
        "m-search": IRouterMatcher<Router>;
        merge: IRouterMatcher<Router>;
        mkactivity: IRouterMatcher<Router>;
        mkcol: IRouterMatcher<Router>;
        move: IRouterMatcher<Router>;
        notify: IRouterMatcher<Router>;
        options: IRouterMatcher<Router, "options">;
        patch: IRouterMatcher<Router, "patch">;
        post: IRouterMatcher<Router, "post">;
        propfind: IRouterMatcher<Router>;
        proppatch: IRouterMatcher<Router>;
        purge: IRouterMatcher<Router>;
        put: IRouterMatcher<Router, "put">;
        report: IRouterMatcher<Router>;
        search: IRouterMatcher<Router>;
        stack: ILayer[];
        subscribe: IRouterMatcher<Router>;
        trace: IRouterMatcher<Router>;
        unlink: IRouterMatcher<Router>;
        unlock: IRouterMatcher<Router>;
        unsubscribe: IRouterMatcher<Router>;
        use: IRouterHandler<Router, string> & IRouterMatcher<Router, any>;
        param(name: string, handler: RequestParamHandler): this;
        route<T extends string | RegExp>(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,
        ): unknown;
    }

    Hierarchy (View Summary)

    Index

    Properties

    all: IRouterMatcher<Router, "all">

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

    delete: IRouterMatcher<Router, "delete">
    get: IRouterMatcher<Router, "get">
    head: IRouterMatcher<Router, "head">
    "m-search": IRouterMatcher<Router>
    mkactivity: IRouterMatcher<Router>
    options: IRouterMatcher<Router, "options">
    patch: IRouterMatcher<Router, "patch">

    post

    post: IRouterMatcher<Router, "post">
    put: IRouterMatcher<Router, "put">
    stack: ILayer[]

    Stack of configured routes

    unsubscribe: IRouterMatcher<Router>

    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

      Returns this

    • Type Parameters

      • T extends string | RegExp

      Parameters

      • prefix: T

      Returns IRoute<T>

    • Parameters

      Returns IRoute