Changelog
Release notes are generated by release-please from Conventional Commits into CHANGELOG.md in the library repository. This page summarizes each release; upgrade steps with before and after code are in the migration guide.
0.2.0
A production-readiness pass over errors, logging, the app builder, datasources, the KV cache and the environment readers.
Breaking changes
- The request-scoped logger variable is renamed from
c.var.loggertoc.var.cwbLogger; usegetRequestLogger(c). DrizzleD1DatasourceandDrizzleD1TenantDatasourceare abstract: subclass them with a uniquereadonly name(the old default names shared one cache namespace).scopedSelect(table, ...conditions)becomesscopedSelect(table, {where, orderBy, limit, offset}).- Response helper
statusparameters areContentfulStatusCode(204 and 304 no longer compile; userespondNoContent()). ApiResponse<T>is a discriminated union (ApiSuccessResponse<T> | ApiErrorResponse).BaseContextVariablesno longer has an index signature.json*OpenAPI helpers require zod schemas.buildPaginationMeta/respondPaginatedthrow a 400BAD_REQUESTApiErrorfor invalidpage,limitortotal.PaginationMetaSchemahas integer fields, a requiredtotalPagesand no defaults.- The global
logshippertype declaration is removed (runtime forwarding is unchanged). ApiError.toJSON()no longer includesstack.createAppthrows for unsupported route methods and duplicate method and path routes.timing(Server-Timing) defaults to development only.- Request ids no longer use
cf-request-id;cf-rayis validated. - Env readers:
boolacceptstrue/false/1/0/yes/no/on/offand returns the default for anything else;int,floatanddatereturn the default instead ofNaNor an Invalid Date; JSON-typed wrangler vars are accepted. - Cache keys for
Map,Setandbigintparams changed; circular params and class instances withouttoJSON()throwTypeError.
Features and fixes
- Errors: 5xx and
criticalerrors are never throttled, with aN errors suppressedwarning after a throttle window.ErrorInfo.stackis the original throw site andErrorInfo.causeholds the serialized cause chain.detailsare always in logs and reports (masked only in responses). Error logs carryrequestId.errors.context.includeClientInfoomits IP and user agent. ApiErroris recognized by aSymbol.forbrand (ApiError.isApiError), so errors from a second copy of the library keep their status.- Non-Error throws get the error envelope instead of escaping
app.fetch. - Logging: the logger never throws (BigInt, circular values);
serializers.reqacceptsc.req;serializers.errkeeps the cause chain (serializeErroris exported); an invalidLOG_LEVELfalls back with a warning (resolveLogLevel,LOG_LEVELS). - New redaction name fragments:
hmac,private,cert,saml,assertion,auth_code,authcode. - App builder:
AppConfig.loggerandAppConfig.requestLogging;requestId: {trustIncomingHeader: false}; module middleware only runs for its own module's routes. - Response helpers:
respondNoContentkeeps previously set headers;meta.pagination.totalPagesis added andMetaSchema.traceIdis documented. - Datasources:
scopedCount, ordering and paging inscopedSelect,requestIdin datasource and cache logs, an overridablecacheBindinggetter. - KV cache:
CacheOptions.revive, a documented JSON-only value contract,KVCacheOptions.logger, and notes on eventual consistency. - Docs: migration guide, support policy, and consumer TypeScript setup notes.
0.1.0 (2026-09-14)
Replaced Prisma with Drizzle ORM, moved the toolchain to TypeScript 7, and hardened errors, logging, caching and multi-tenancy.
Breaking changes
- Datasources: the Prisma datasources and tenant extension are removed. Use
DrizzleD1DatasourceandDrizzleD1TenantDatasource(tenant state is per instance; use thescoped*helpers).drizzle-orm0.45.x is an optional peer dependency. hono(^4.13),chanfana(^3.4) andzod(^4.4.3) are peer dependencies. The published types work with TypeScript 5.9 to 7 consumers and need Workers globals.- The
registrysingleton export is removed;createAppcreates oneEndpointRegistryper app. AppConfig.openApimust return the chanfana router (OpenAPIRouter).- The
KVCacheconstructor takes an options object; cached values are wrapped as{value}and keys changed (SHA-256,nullsignificant,toJSONhonored), so existing entries are ignored. KVCache.invalidate/clearAllandAbstractDatasource.clearstay within a KV operation budget and return{deleted, complete, cursor, failed}.AbstractDatasource.updateLoggerName()is removed;withCachedefaults to the datasourcenamenamespace.- Only
NODE_ENVvaluesdevelopment,dev,testandlocalcount as non-production. - 5xx messages and details are masked in production; 4xx messages are returned for
ApiErrorandHTTPException, and other errors need a transformer-suppliedmessage. Stack traces are logged by default, never returned. globalThis.requestContextlog enrichment is removed (it mixed concurrent requests) in favor of a request-scoped logger.DrizzleD1TenantDatasource.scopedSelectresolves to rows instead of a query builder.- Log lines use
time(ISO) instead oftimestamp.
Features and fixes
createApp({middleware})andApiModule.middlewarerun middleware such as auth before module routes.- chanfana errors (schema validation,
InputValidationException,NotFoundException, ...) use the standard envelope; validation failures return 422VALIDATION_ERRORwith{field, message, code}details. - Unknown routes return the JSON
NOT_FOUNDenvelope. - MIT license and complete package metadata; CI, release, commitlint, PR title, zizmor and Dependabot workflows.
- Tenant datasource caches are namespaced per tenant;
scopedUpsertupdates only the current tenant's conflicting rows and acceptssqlvalues; scoped write helpers return narrow query objects. - Sensitive query parameters are redacted in error context and logged URLs (
excludeQueryParams,addSensitiveQueryParams,redactQueryParams,redactUrl). createErrorHandler(config)implements custom logger, error reporter viawaitUntil, header redaction, message truncation, classifier, transformer, rate-limited reporting andgetMetrics().- Hono
HTTPExceptions keep their status;respondErrorbodies includeerror.id;respondPaginatedaddshasNext/hasPrev. - Route paths are normalized; request logs show the real request path.
- The logger redacts sensitive headers and includes
env,serviceandruntime;SERVICE_NAMEsets the service name. - KV cache: SHA-256 keys, falsy values cached, background writes via
waitUntil, cursor pagination on invalidate, TTL clamped to KV's 60-second minimum;KVCacheis exported. - Tooling: tsdown with TypeScript 7 declarations, oxlint with type-aware rules, a
bun testsuite against local D1 and KV.