@nestjs/core
Version:
The core of NestJS, a TypeScript framework for Node.js backends: modules, dependency injection and the request pipeline, on Express, Fastify or node:http.
29 lines (28 loc) • 1.34 kB
TypeScript
import { ResolvedRoute } from './interfaces/resolved-route.interface.js';
/**
* Static utility class that orders resolved routes by specificity so the
* underlying HTTP adapter registers more specific patterns first.
* Stateless — every method takes everything it needs as parameters.
*/
export declare class RouteSpecificitySorter {
/**
* Lower rank means more specific. A literal segment beats one mixing
* text and params (`v:version`), which beats a named param, which beats
* a named wildcard. A position that is absent on one side means the
* path is shorter at that point. A shorter path with a wildcard is the
* least specific of all (`missing`), as the wildcard can absorb the
* extra segments. Without one, it ranks after a literal but before the
* other kinds (`end`): those can sit in an optional group
* (`/users{/:id}`, `/{*path}`) and then also match the shorter path.
*/
private static readonly SEGMENT_KIND_RANK;
/**
* Returns a new array of routes sorted from most-specific to
* least-specific. Routes that tie on specificity keep their original
* declaration order.
*/
static sort(routes: ResolvedRoute[]): ResolvedRoute[];
private static comparePathSpecificity;
private static getEndKind;
private static rankSegmentByKind;
}