Skip to content

@centralping/ergo-router

Version [0.3.0]

Added

  • paginate pipeline config key. Declarative route configs accept a paginate key that wires ergo’s paginate() middleware into Stage 1 (Negotiation), after URL parsing. Automatically includes URL parsing when active (regardless of HTTP method). When enabled, send() receives paginate: true for automatic Link header and X-Total-Count generation. Supports offset-based (paginate: true) and cursor-based (paginate: {strategy: 'cursor'}) pagination strategies via ergo’s pagination primitives. (#71)

  • presets.jsonApi convenience export. A deeply frozen RouterOptions object that enables transport-level request ID and security headers, and restricts content negotiation to application/json. Consumers spread it into createRouter() for one-liner JSON API configuration. Excludes deployment-specific concerns (auth, CORS origin, rate limiting). Available via import {presets} from '@centralping/ergo-router'. (#70)

  • Typed RouteConfig with generic accumulator. Hand-written TypeScript declaration overrides (types-override/) provide precise type information for declarative route configuration. Each middleware key is typed with its specific ergo option interface (e.g., AcceptsOptions, BodyOptions) instead of generic object | boolean. The execute callback’s domain accumulator accepts a generic type parameter RouteConfig<A> (defaults to Record<string, unknown>), enabling consumers to annotate their accumulator shape for type-safe property access. RouterOptions, TransportOptions, GracefulOptions, and the Router instance are also fully typed. Adopts the types-override pattern established in @centralping/ergo. (#68)

Changed

  • Config value type validation at registration time. Declarative route config values, createRouter() options, and options.defaults are now validated for correct types at registration time. Invalid values (e.g., timeout: 'five seconds', rateLimit: 42, validate: [1,2,3]) throw immediately with descriptive error messages instead of causing cryptic runtime errors at request time. Pipeline middleware keys accept boolean | object; route option keys enforce their specific types (send: object, noSend: boolean, catchHandler: function); router option keys enforce per-key types. Value type errors always throw regardless of strict setting. (#69)
  • Bumped @centralping/ergo peer dependency range to >=0.3.0 <0.4.0 (was >=0.2.0 <0.3.0). Floor bumped to 0.3.0 for paginate middleware factory import. (#71)