Reminist - v1.0.6
    Preparing search index...

    Class Reminist<Context, Keys>

    Reminist - A high-performance, type-safe router based on a Radix Tree.

    Supports static routes, dynamic parameters, catch-all, and wildcards with full TypeScript inference for parameters and stored data.

    Type Parameters

    • const Context extends Record<string, any> = {}

      A record mapping path templates to their associated data types.

    • const Keys extends readonly string[] = readonly string[]

      A readonly array of keys (e.g., HTTP methods) used to group routes.

    Index

    Constructors

    • Initializes a new Reminist router instance.

      Type Parameters

      • const Context extends Record<string, any> = {}

        A record mapping path templates to their associated data types.

      • const Keys extends readonly string[] = readonly string[]

        A readonly array of keys (e.g., HTTP methods) used to group routes.

      Parameters

      Returns Reminist<Context, Keys>

    Methods

    • Registers a new route in the router.

      Type Parameters

      • P extends string

        The path template string.

      • S

        The type of data to store with this route.

      Parameters

      • key: Keys[number]

        The key group for this route (e.g., 'GET').

      • path: P

        The route path template (e.g., '/users/:id').

      • store: S

        The data/handler to associate with this route.

      Returns Reminist<Context & { [K in string]: S }, Keys>

      A new Reminist instance with updated context types.

    • Deletes a registered route.

      Type Parameters

      • P extends string | string & {}

        The route path to delete.

      Parameters

      • key: Keys[number]

        The key group containing the route.

      • path: P

        The path template to remove.

      Returns Reminist<Omit<Context, P extends string ? P : string>, Keys>

      The Reminist instance with updated context types.

    • Finds a registered route matching the given path.

      Type Parameters

      • const P extends string | string & {}

        The literal path string to search for.

      Parameters

      • key: Keys[number]

        The key group to search within (e.g., 'GET').

      • path: P

        The actual path to match.

      Returns {
          node:
              | Node<
                  Context[MatchRoute<
                      P extends string ? P : string,
                      Extract<keyof Context, string>,
                  >],
                  string,
                  true,
              >
              | null;
          params: ExtractParams<
              MatchRoute<
                  P extends string ? P : string,
                  Extract<keyof Context, string>,
              >,
          >;
      }

      An object containing the matched node (if any) and extracted parameters.

    • Retrieves all registered routes for a specific key or all keys.

      Type Parameters

      • K extends string

      Parameters

      • key: K

        Optional key to filter routes.

      Returns string[]

      If key is provided, an array of routes. Otherwise, a record of all keys and their routes.

    • Retrieves all registered routes for a specific key or all keys.

      Returns { [K in string]: string[] }

      If key is provided, an array of routes. Otherwise, a record of all keys and their routes.

    • Checks if a route exists for the given path.

      Type Parameters

      • const P extends string | string & {}

      Parameters

      • key: Keys[number]

        The key group to check.

      • path: P

        The path to check for.

      Returns boolean

      True if the path is registered.