@centralping/ergo-router
Version [0.4.1]
Added
-
Accumulator type inference via
defineGet/definePost/defineRoutehelpers. (#91) New exported functions that infer the domain accumulator type from enabled middleware config keys, providing fully typedaccin execute callbacks without manual generic annotation.defineGetauto-includes{url: UrlResult}for GET/DELETE;definePostauto-includes{body: BodyResult}for POST/PUT/PATCH;defineRouteis method-agnostic. Keys set tofalsecorrectly suppress their accumulator type.paginatetransitively includes URL types.import {defineGet} from '@centralping/ergo-router';router.get('/users/:id', defineGet({authorization: true, url: true},(req, res, acc) => {acc.auth; // AuthorizationResultacc.url.query; // Record<string, string | string[]>acc.route.params; // Record<string, string>}));Known limitation: Middleware enabled via
createRouter({defaults: {...}})is not visible to type inference. Add the key explicitly to the route config for typed access. -
New type exports:
RouteConfigBase,InferAccumulator<C>,AutoGetAccumulator<C>,AutoPostAccumulator<C>— available for advanced use cases and custom inference helpers. -
timingoption oncreateRouter()forX-Response-Timeheader. (#93) Passtiming: truefor defaults ortiming: {header?, precision?}for custom configuration. Measures pipeline execution time via ares.writeHeadinterception using the sharedapplyResponseTimingprimitive from@centralping/ergo/lib/response-time. Zero overhead when disabled (default). Short-circuit responses (404, 405, 415, 429) are intentionally excluded — timing measures pipeline execution, not transport/routing overhead.
Changed
- Bumped
@centralping/ergopeer dependency floor to>=0.4.1 <0.5.0(was>=0.4.0 <0.5.0). Floor bumped to 0.4.1 forapplyResponseTimingimport fromlib/response-time. (#93)