interface Route

One registered route: the parsed shape get()/post()/… store and #findRouteHandler matches against.

const route: Route = {
  path: '/tests/:id',
  handler: (_req, res) => res.end('ok'),
  paramNames: ['id'],
  isWildcard: false,
  compiledRegex: null,
};
route.paramNames; // ['id']

Properties

path: string

The registered path pattern, e.g. /tests/:id or the /* wildcard.

The handler #handleRequest dispatches to when this route matches.

paramNames: string[]

Names of the :param segments, in order of appearance.

isWildcard: boolean

Whether this is the catch-all /* route.

optional
paramValues: string[]

The captured segment values from the most recent match; feeds req.params.

compiledRegex: RegExp | null

Prebuilt matcher for parameterised paths; null for static ones.

Usage

import { type Route } from "lib/web/index.ts";