Skip to content

@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 via onStartup: ({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 shared lib/resolve-config.js utility. The config resolution function (route config > defaults > omitted) was duplicated in pipeline-builder.js and openapi.js. Now shared by all three consumers: pipeline-builder, openapi, and route-table. Internal refactor — no behavior change.

  • Route-level send now merges with router-level send instead of replacing it. (#120) Previously, auto-wrap.js used nullish coalescing (routeOpts.send ?? routerOptions.send) which treated any defined route-level send object as a complete replacement for router-level send options. When addRoute() auto-injected {paginate: true} or {prefer: true} into route-level send, router-level options like errorFormatter were 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 to undefined explicitly (e.g., send: {errorFormatter: undefined}).

Fixed

  • Typed generateOpenAPI signature and OpenAPIDocument return type. (#124) The generateOpenAPI function’s router parameter and return type were both object in the generated .d.ts, forcing consumers to cast. The router parameter is now typed as Router and the return type is OpenAPIDocument, a new interface modeling the OpenAPI 3.1 document structure at the depth generateOpenAPI produces. Supporting interfaces (OpenAPIInfo, OpenAPIOperation, OpenAPIPathItem, OpenAPIParameter, OpenAPIRequestBody, OpenAPISecurityScheme, OpenAPIComponents, GenerateOpenAPIOptions) are exported from the main entry point and the ./openapi sub-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.