Skip to content

RouteResolverEntry ​

All entries have this union type:

ts
type RouteResolverEntry =
  | { kind: "api"; route: ApiRoute }
  | { kind: "page"; route: PageRoute };

Check the kind property to determine which type you're dealing with.

Common Properties (RouteEntry) ​

Both ApiRoute and PageRoute extend RouteEntry with these properties:

id - Unique identifier (e.g., "users_id_67567456")

name - Route name (e.g., "users/[id]")

folder - Either "api" or "pages", indicating which directory the route is in

file - Path to route file, relative to the folder

fileFullpath - Absolute path to the route file

pathTokens - Array of path segments with parameter information

pathPattern - path-to-regexp pattern

PathToken Structure ​

Each token in the route path has this structure:

ts
export type PathToken = {
  kind:
    | "static"   // segment is purely static
    | "param"   // segment is a single pure param (no static parts)
    | "mixed"; // segment has both static and param parts

  // original segment string, eg. [id] or {name} or {...path}
  orig: string;

  // path-to-regexp pattern obtained from original segment,
  // eg. :id or {/:name} or {/*path}
  pattern: string;

  // parsed parts of the segment
  parts: Array<PathTokenStaticPart | PathTokenParamPart>;
};

Static segments have param as undefined. Dynamic segments have param populated with metadata.

ApiRoute Properties ​

API routes have additional properties for type information:

params - Route parameter metadata:

  • id - Type identifier for params
  • schema - Array of parameter tokens (subset of PathToken containing only dynamic segments)
  • resolvedType - Flattened type information (if resolveTypes: true)

numericParams - Names of parameters refined as numbers

optionalParams - Whether route has any optional parameters

methods - HTTP methods this route handles (GET, POST, etc.)

typeDeclarations - Type definitions found in the route file

payloadTypes - Request body type information per method

responseTypes - Response type information per method

referencedFiles - Absolute paths to files this route imports from

PageRoute Properties ​

Page routes have simpler parameter information:

params - Route parameter schema:

  • schema - Array of parameter tokens (subset of PathToken containing only dynamic segments)

Released under the MIT License.