@centralping/ergo-router
Version [0.6.0]
Added
router.routeTable()introspection method. (#122) Returns a formatted multi-line string summarizing registered routes, enabled middleware (in pipeline stage order), and transport configuration. Designed for startup logging viaonStartup: ({log}) => log.info(router.routeTable()). Non-declarative routes (raw functions or arrays) are marked(custom). Methods are right-padded for visual alignment.
Changed
-
resolve()extracted to sharedlib/resolve-config.jsutility. The config resolution function (route config > defaults > omitted) was duplicated inpipeline-builder.jsandopenapi.js. Now shared by all three consumers: pipeline-builder, openapi, and route-table. Internal refactor — no behavior change. -
Route-level
sendnow merges with router-levelsendinstead of replacing it. (#120) Previously,auto-wrap.jsused nullish coalescing (routeOpts.send ?? routerOptions.send) which treated any defined route-levelsendobject as a complete replacement for router-level send options. WhenaddRoute()auto-injected{paginate: true}or{prefer: true}into route-level send, router-level options likeerrorFormatterwere silently dropped. Send resolution now uses spread-merge ({...routerOptions.send, ...routeOpts.send}) — router-level is the base, route-level overrides on conflict. This aligns with the route-config-over-defaults precedence model. Routes that need to suppress a router-level send option can set it toundefinedexplicitly (e.g.,send: {errorFormatter: undefined}).
Fixed
- Typed
generateOpenAPIsignature andOpenAPIDocumentreturn type. (#124) ThegenerateOpenAPIfunction’srouterparameter and return type were bothobjectin the generated.d.ts, forcing consumers to cast. Therouterparameter is now typed asRouterand the return type isOpenAPIDocument, a new interface modeling the OpenAPI 3.1 document structure at the depthgenerateOpenAPIproduces. Supporting interfaces (OpenAPIInfo,OpenAPIOperation,OpenAPIPathItem,OpenAPIParameter,OpenAPIRequestBody,OpenAPISecurityScheme,OpenAPIComponents,GenerateOpenAPIOptions) are exported from the main entry point and the./openapisub-path. All interfaces use template-literal index signatures ([key: \x-${string}`]: unknown`) restricting extension members to the `x-*` prefix required by OpenAPI 3.1 §4.1.