@centralping/ergo
Version [0.5.0]
Added
-
nowclock option onMemoryStoreconstructor. (#150) Accepts an optional clock function (() => number) for deterministic time control. Default isDate.now— no behavior change for existing consumers. Enables portable test patterns without Node-specific mock timers. -
responseSchemaoption forsend()andhandler(). (#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 withstatusCode < 400. Resolution order: exact match → range → default. New shared primitivelib/response-schema.jsavailable 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-erroras informational checks. README documents runtime support status and known gaps. -
onResponsepost-send lifecycle hook forhandler(). (#140) Observation callback fired aftersend()completes. Receives(req, res, responseInfo, domainAcc)whereresponseInfois 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.jsshared primitive. (#140) Pure functionbuildResponseInfo(req, res, startTime)for constructing response info snapshots. Consumed byhttp/handler.jsandergo-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 tovalidate()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 emitERGO_VALIDATE_UNKNOWN_KEYwarnings. -
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-erroras 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(directprocess.emitWarningassignment),lib/rate-limit.spec.unit.js(injectable clock). No production behavior changes except thenowparameter. -
Declared
@types/nodeas optional peer dependency for TypeScript consumers. (#134) TypeScript consumers compiling withskipLibCheck: falsereceived errors from ergo’s.d.tsfiles becauseimport('node:http')type references require@types/node. The package is now declared as an optional peer dependency (>= 22, matchingengines.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.