Skip to content

v0.9.1

Choose a tag to compare

@github-actions github-actions released this 16 Oct 07:27
· 23 commits to main since this release

ExisJS Release v0.9.1

Release Date: 2026-10-16
Type: Patch: Bug Fixes, Conditional Requests & Request Path Cleanup
Affected Packages: exisjs, create-exisjs, @exisjs/fetch (all aligned to 0.9.1)


Highlights

Fixes from two reports on 0.9.0: the 0.8.1 test suite re-run against 0.9.0 (E-01, E-02), and a CRM built on 0.9.0 (nested object schemas). No breaking changes.

ETags and conditional requests follow RFC 9110 everywhere. Automatic ETags, static files and downloads share one evaluator for If-Match, If-Unmodified-Since, If-None-Match and If-Modified-Since. The new res.checkPreconditions() lets handlers answer 304 from a version column before loading data, and refuse lost updates with 412 / 428.

Fixed

  • A returned Buffer was sent as JSON behind a boundary wrapper (E-01, was T-13). A boundary handle(ctx, next) / default-export wrapper took the route's response back and re-sent every object with res.json, so a Buffer became {"type":"Buffer","data":[...]}, and res.json(5) or res.json(null) became text. The wrapper now replays the response through the method the route used. A wrapper that awaits next() but returns nothing also sends the route's response; before, the request stayed open.
  • .optional() on a nested tex.object was ignored. Address.optional(), tex.object(shape).partial().optional() and extend({ address: Address.optional() }) all required the key. The modifier now carries through tex.object, tex.array items, extend, merge, pick, omit and partial, and the OpenAPI output agrees with the validator.
  • partial() skipped nested objects. A nested object whose own fields were optional stayed required after partial().
  • A plain nested shape crashed. tex.object({ address: { city: tex.string() } }) failed with s.slice is not a function, although its types allow it. It now works the same as tex.object({ city: ... }).
  • An array item error was listed twice in the validation error details.
  • Unclear error for a missing field schema. tex.object({ address: undefined }) threw Cannot read properties of undefined (reading 'length'); it now throws tex.object(): field "address" has no schema (got undefined). A transformed or discriminated-union schema used as a field, which never worked, gets a clear error too.
  • The generated AGENTS.md pointed to node_modules/exisjs/docs/, which does not exist. The docs ship in node_modules/exisjs/dist/docs/.
  • The API reference index linked to absolute paths on the author's machine; the links are relative now.
  • The 03-all-features example sent X-Powered-By (E-02).
  • Binary request bodies were corrupted. The body was decoded as UTF-8 text and turned back into bytes, so req.buffer() and @RawBody() replaced every byte that is not valid UTF-8 (images, protobuf, compressed or signed payloads). The bytes are now kept as received, and text is decoded from them only when asked for.
  • @RawBody() hid body errors. A body over bodyLimit reached the handler as an empty Buffer instead of answering 413.
  • The test client JSON-encoded Buffers. .send(buffer) in createTestApp sent {"type":"Buffer","data":[...]}; it now sends the bytes, as application/octet-stream unless a content type is set.
  • In development, res.cookie() copied each cookie into an X-Set-Cookie header, which page scripts can read, so httpOnly cookies were exposed to JavaScript. The header is gone.
  • res.html() sent no Content-Length and skipped ETag / 304 handling; it now goes through res.send().
  • A thrown non-Error value in a functional route is handled the same way as in class controllers.

Conditional Requests (ETag, 304, 412)

  • New res.checkPreconditions({ etag, lastModified, exists }, { required }). On GET/HEAD it sets ETag / Last-Modified and answers 304 when the client's copy is current (returns true). On writes it throws 412 PRECONDITION_FAILED when If-Match / If-Unmodified-Since no longer hold or If-None-Match: * targets an existing resource, and 428 PRECONDITION_REQUIRED with { required: true } when the client sent no precondition.
  • One RFC 9110 §13.2.2 evaluator for automatic ETags, serveStatic, res.download(path) and req.fresh: the standard evaluation order, strong comparison for If-Match, weak for If-None-Match, lists, *, and tags containing commas. Unparsable dates are ignored.
  • If-None-Match lists and weak tags now match on static files (only an exact single string matched before), and If-Modified-Since works: static files and downloads send Last-Modified.
  • A Cache-Control: no-cache request header no longer disables revalidation. It made the server answer 200 with the full body even when the client's tag matched; RFC 9110 has the origin evaluate conditionals regardless.
  • 304 responses carry no body metadata. Content-Type, Content-Length and Content-Encoding are removed; ETag, Last-Modified, Cache-Control and Vary are kept.
  • A failed If-Match on a read answers 412 with the standard error envelope.
  • res.download(path) supports ETag, Last-Modified, 304 and 412.
  • Automatic ETags (etag: true) only on successful GET/HEAD responses. Writes and error responses were hashed for nothing. Hashing uses Node's one-shot crypto.hash() where available (about 35% faster) and no longer copies string bodies into a Buffer first.
  • serveStatic no longer blocks the event loop: it picks the .br / .gz variant with async stat instead of two existsSync calls per request. It always sends Vary: Accept-Encoding, so a cache never serves the Brotli file to a client that did not ask for it.
  • br;q=0 is a refusal. serveStatic and compression() treated any mention of an encoding in Accept-Encoding as acceptance.
  • Static file ETags are weak (W/"size-mtime", as send / serve-static use): file metadata does not prove two files are byte-identical.
  • Dropped the fresh dependency; req.fresh uses the same evaluator.
  • The in-process test client closes its connection once the response is complete. Tests of static files and downloads took about 4 s per request while it waited for the keep-alive socket to time out.

Database

  • @Transactional handed a transaction to concurrent requests. It wrote the transaction onto the service instance (this.db = tx) for the length of the call; services are shared singletons, so any other request using the same service meanwhile ran its queries inside that transaction, and could be committed or rolled back with it. The transaction is now visible only in the async context of the call (and the methods it calls), through AsyncLocalStorage; this stays the real instance, so #private fields keep working.
  • Databases connect in parallel at boot. connectAll() connected one after another, so boot took the sum of every connection time; it now takes the slowest one. A failure names every database that failed (error.failures), the others stay connected, and a retry only reconnects the failed ones.
  • Health checks run in parallel, with a timeout. One unresponsive database hung /_ready (and the load balancer marked the instance dead on its own timeout); each check now fails after healthTimeoutMs (default 5 s) with status: 'error'. Probes that arrive while a check is running share its result. Custom healthcheck.checks get the same 5 s limit.

Changed

  • 404s no longer scan the route table. Answering 405 / Allow on a miss looked at every registered route on every unmatched request; the router now keeps the set of methods in use, so a miss costs the same with 10 or 10,000 routes.
  • Functional controllers (controller({ ... }) in route.ts files) work out guards, interceptors and the route timeout once per route instead of on every request, and build the guard context only when a guard or interceptor needs it.
  • fast-json-stringify (used for response schemas when installed) is loaded on first use instead of at startup.
  • Removed unused request/response pooling code (ExisRequest.init() / cleanup(), ExisResponse.init()).
  • New npm run bench:pipeline: per-request framework cost without the network, for checking routing, request and response changes.

Dependencies

  • pino 10.4.0 and pino-pretty 13.2.0 (runtime, exisjs).
  • Removed fresh (replaced by the built-in conditional request evaluator).
  • Development and examples: typescript-eslint / @typescript-eslint/* 8.71.2, hono 4.13.13 (benchmarks), mongoose 8.24.5 (02-bookstore).

Added

  • .nullable() and .nullish() on object schemas (TexEngine), next to .optional().

Documentation

  • Validation: modifiers on nested object schemas, and plain nested shapes.
  • Boundaries: what a handle(ctx, next) wrapper's return value does.
  • Middleware: async middleware is awaited, and a thrown HttpError becomes the response.

Upgrade Notes

npm install exisjs@0.9.1
  • Databases registered with registerDatabase() now connect at the same time. If one database's connect() relies on another being connected first, connect the second inside the first's connect().
  • Static file ETags change format once (strong to weak), so browsers download each file one more time after the upgrade.
  • If your clients send If-Match on GET requests to routes with etag: true, a stale tag now answers 412 instead of 200.
  • Code that relied on the development-only X-Set-Cookie header: read cookies from Set-Cookie in your HTTP client or the browser's developer tools instead.
  • If you worked around nested optional objects with a hand-written rule such as `object<…> | optional | nullable`, you can switch back to Address.optional() or Address.nullish().
  • Projects created before 0.9.0 keep the old template defaults after upgrading. Check two places by hand: docs: { enabled: process.env.NODE_ENV !== 'production' } in exis.config.ts, and no X-Powered-By header in src/http/boundary.ts.

Full Changelog: v0.9.0...v0.9.1