Documentation
    Preparing search index...

    RoutesScanner is responsible for scanning application routes, extracting their controllers, validators, request and response types.

    The RoutesScanner analyzes route definitions to extract TypeScript type information for request validation, response types, and controller methods. It supports custom rules for overriding default behavior and provides hooks for extending functionality.

    const scanner = new RoutesScanner(appRoot, [rules])
    scanner.defineResponse((route, controller) => {
    return { type: 'CustomResponseType', imports: [] }
    })
    await scanner.scan(routes)
    const scannedRoutes = scanner.getScannedRoutes()
    Index

    Constructors

    Properties

    ui: {} = ...

    CLI UI instance to log colorful messages and progress information

    pathsResolver: PathsResolver = ...

    The paths resolver is used to convert subpath and package imports to absolute paths

    rules: RoutesScannerRules = ...

    The rules to apply when scanning routes

    Methods

    • Register a callback to self compute the response types for a given route. The callback will be executed for all the routes and you must return undefined to fallback to the default behavior of detecting types

      Parameters

      • callback: (
            route: ScannedRoute,
            controller: ScannedController,
            scanner: RoutesScanner,
        ) => AsyncOrSync<undefined | { type: string; imports: string[] }>

        Function to compute response types for routes

      Returns this

      This RoutesScanner instance for method chaining

    • Register a callback to self compute the request types for a given route. The callback will be executed for all the routes and you must return undefined to fallback to the default behavior of detecting types

      Parameters

      • callback: (
            route: ScannedRoute,
            controller: ScannedController,
            scanner: RoutesScanner,
        ) => AsyncOrSync<undefined | { type: string; imports: string[] }>

        Function to compute request types for routes

      Returns this

      This RoutesScanner instance for method chaining

    • Invalidating a controller will trigger computing the validators, request types and the response types.

      Parameters

      • controllerPath: string

        Path to the controller file to invalidate

      Returns Promise<void>

    • Scans an array of Route list items and fetches their validators, controllers, and request/response types.

      This is the main method that processes all routes and extracts their type information for code generation purposes.

      Parameters

      Returns Promise<void>