Stone.js API
    Preparing search index...

    Middleware options.

    This interface defines the configuration options for marking a class as middleware.

    interface MiddlewareOptions {
        alias?: string | string[];
        global?: boolean;
        layer?: "kernel" | "app" | "router";
        params?: unknown[];
        priority?: number;
        singleton?: boolean;
    }
    Index
    alias?: string | string[]

    The alias of the middleware.

    global?: boolean

    Set as Kernel middleware

    layer?: "kernel" | "app" | "router"

    Which pipeline the middleware belongs to.

    • app (the default): the application's own middleware, run for every event.
    • kernel: the kernel's own pipeline, the same place global: true puts it.
    • router: after a route has been matched, which is the only layer where a middleware can read the route and what it declares.

    The last one is why this exists. A middleware that needs the matched route, to read a permission or a resource a route declared, had nowhere to be declared from: both branches of the decorator led to the kernel, where no route has been matched yet, so such a middleware could only be registered from a blueprint. A module is activated by its decorator or by its blueprint, and both must be able to say the same things.

    params?: unknown[]

    The params to pass to the middleware.

    priority?: number

    The execution priority of the middleware.

    singleton?: boolean

    Whether the middleware should be treated as a singleton.