Router Inspection
XyPriss Router exposes a built-in inspection API that allows you to programmatically read the entire routing state at runtime. This is critical for building documentation generators, health dashboards, and debugging tools.
Registry Export
Use router.toRegistry() to get a fully serializable snapshot of the routing tree.
typescript
const registry = router.toRegistry();
console.log(JSON.stringify(registry, null, 2));| Field | Description |
|---|---|
| method | HTTP verb (GET, POST, etc.). |
| path | The full registered path string. |
| params | Extracted parameters and regex constraints. |
| hasGuards | True if declarative guards are present. |
Router Statistics
router.getStats() returns high-level aggregated metrics about the router instance.
typescript
const stats = router.getStats();
console.log(`Total routes: ${stats.totalRoutes}`);OpenAPI & Swagger Integration
The toRegistry() output is the primary data source for the official xypriss-swagger plugin, enabling zero-config API documentation.
typescript
import { SwaggerPlugin } from "xypriss-swagger";
createServer({
plugins: {
register: [
SwaggerPlugin({
path: "/api-docs",
title: "My System API",
}),
],
},
});Custom Metadata
You can add custom fields to any route via
meta.openapi. These fields will be automatically merged into the generated OpenAPI specification.HTTP Methods Reference
A complete reference guide for all supported HTTP methods in XyPriss.
