Documentation
    Preparing search index...

    Entry to add a middleware to a given middleware stack via the CodeTransformer. Represents middleware configuration for server, router, or named middleware stacks.

    const corsMiddleware: MiddlewareNode = {
    path: '@adonisjs/cors/cors_middleware',
    position: 'before'
    }

    const namedMiddleware: MiddlewareNode = {
    name: 'auth',
    path: '#middleware/auth_middleware',
    position: 'after'
    }
    type MiddlewareNode = {
        name?: string;
        path: string;
        position?: "before" | "after";
    }
    Index

    Properties

    Properties

    name?: string

    Required for named middleware. The key name under which the middleware will be registered in the named middleware collection.

    path: string

    The import path to the middleware file. Can be a package import, subpath import, or relative path.

    '@adonisjs/static/static_middleware'
    '#middlewares/silent_auth'
    './middleware/custom_middleware.js'
    position?: "before" | "after"

    The position to add the middleware in the stack. 'before' adds at the beginning (runs first), 'after' adds at the end (runs last).

    'after'