Skip to content

@centralping/ergo

Version [0.5.0]

Added

  • now clock option on MemoryStore constructor. (#150) Accepts an optional clock function (() => number) for deterministic time control. Default is Date.now — no behavior change for existing consumers. Enables portable test patterns without Node-specific mock timers.

  • responseSchema option for send() and handler(). (#137) Schema-based response body projection that strips undeclared properties before JSON serialization. Accepts a map of status code (or range key like '2xx', 'default') to JSON Schema objects. Projectors are compiled at factory time for zero per-request schema parsing overhead. Only applies to Object bodies with statusCode < 400. Resolution order: exact match → range → default. New shared primitive lib/response-schema.js available via deep import @centralping/ergo/lib/response-schema.

  • Multi-runtime CI: Deno 2.x and Bun 1.x test jobs. (#138) CI now runs the full test suite on Deno and Bun alongside Node.js 22/24. Both runtimes pass all contract tests (100%) and nearly all unit tests (Deno 96.7%, Bun 99.4%) via their Node.js compatibility layers. Jobs use continue-on-error as informational checks. README documents runtime support status and known gaps.

  • onResponse post-send lifecycle hook for handler(). (#140) Observation callback fired after send() completes. Receives (req, res, responseInfo, domainAcc) where responseInfo is a snapshot of {statusCode, headers, method, url, bodySize, duration}. Hook errors are swallowed — cannot affect the response. Async hooks are awaited. OTEL span duration includes hook execution time.

  • lib/response-info.js shared primitive. (#140) Pure function buildResponseInfo(req, res, startTime) for constructing response info snapshots. Consumed by http/handler.js and ergo-router/lib/auto-wrap.js. Exported via @centralping/ergo/lib/response-info.

  • validate() shorthand form for body-only schemas. (#135) Pass a raw JSON Schema object directly to validate() instead of wrapping it in {body: schema}. The shorthand is detected when the first argument contains JSON Schema keywords (e.g. type, properties, required) and none of the targeted keys (body, query, params). The targeted form is unchanged and takes precedence when any targeted key is present. Objects that match neither form still emit ERGO_VALIDATE_UNKNOWN_KEY warnings.

  • Multi-runtime CI: Deno 2.x and Bun 1.x test jobs. (#138) CI now runs the full test suite on Deno and Bun alongside Node.js 22/24. Both runtimes pass all contract tests (100%) and nearly all unit tests (Deno 96.7%, Bun 99.4%) via their Node.js compatibility layers. Jobs use continue-on-error as informational checks. README documents runtime support status and known gaps.

Documentation

  • Naming discoverability audit: send, accepts, compose — keep decision. (#139) Evaluated all three names against ecosystem conventions, alternative candidates, and affected surface area. Conclusion: names are accurate, alternatives are equally or more ambiguous, and the perceived confusion stems from architectural differences with Express/Fastify/Koa — not naming errors.

Fixed

  • Test suite portability for Deno and Bun. (#150) Replaced Node-specific test infrastructure (@opentelemetry/sdk-trace-node, mock.method(), mock.timers) with portable patterns in three test files: http/tracing.spec.unit.js (mock tracer via {tracer} factory option), http/validate.spec.unit.js (direct process.emitWarning assignment), lib/rate-limit.spec.unit.js (injectable clock). No production behavior changes except the now parameter.

  • Declared @types/node as optional peer dependency for TypeScript consumers. (#134) TypeScript consumers compiling with skipLibCheck: false received errors from ergo’s .d.ts files because import('node:http') type references require @types/node. The package is now declared as an optional peer dependency (>= 22, matching engines.node), following the ecosystem standard used by Express, Fastify, and Koa. JavaScript-only consumers are unaffected — npm prints an informational warning but does not fail.