Skip to content

Releases

BareJS v0.2.12

Choose a tag to compare

@xarhang xarhang released this 03 Dec 09:38

What's New in BareJS v0.2.12

Core Type Safety, Client Disconnect & Streaming RPC

  • Compile-Time Route Params & Return Inference: Added ExtractRouteParams<P> and typed (path, handler) overloads on BareJS and BareRouter so schema-less routes infer ctx.params and bareTreaty return types without TS7006 implicit any.
  • Client Disconnect AbortSignal (ctx.signal & ctx.onAbort()): Lazy, zero-overhead disconnect signal on Context and EdgeContext.
  • Compile-Time Typed SSE Streaming & Rich Type Transformer: ctx.sse<T>() returns SseResponse<T>, automatically unwrapped to AsyncIterable<T> in bareTreaty / bareClient with options.signal cancellation, plus opt-in bareTransformer (Date, Map, Set, BigInt, RegExp, URL; superjson-compatible).

3 New Zero-Dependency Optional Subpaths (0 bytes in core/edge)

  • barejs/otel (3.5 KB): OpenTelemetry OTLP/HTTP JSON (v1/traces) batch exporter (otel(), createOtlpExporter()) for Grafana Tempo, Datadog, Honeycomb, and Jaeger.
  • barejs/store (5.4 KB): Unified BareStore adapters (memoryStore, sqliteStore, upstashStore, kvStore) + middleware bridges (toRateLimitStore, toCacheStore, toIdempotencyStore) for distributed rateLimit(), cache(), idempotency(), and workflows.
  • barejs/workflow (5.0 KB): Durable, crash-resumable multi-step workflows (defineWorkflow, step.run, step.sleep, step.waitForEvent, sendEvent, resume) backed by BareStore.

Performance, Reliability & Docs

  • Single-Handler Async Fast-Path (Bun.peek): Eliminated redundant async wrapper Promises on single-handler routes (~25% faster Async Handler + Query Parsing, ~31% fewer allocations; BareJS now leads all 4 core benchmark scenarios by >10%).
  • Deno 2.x barejs/queue Fix & Multi-Runtime Release Gate: Fixed queue.drain() timer ref on Deno 2.x and gated publish.yml on full Bun + Node.js (22 & 24) + Deno (2.x) verification before OIDC npm publishing.
  • Expanded Docs & Examples: Doubled docs/reference.md, added docs/migration.md, docs/cookbook.md, 4 new runnable examples, and expanded llms-full.txt to 104 KB (537 tests / 7,097 assertions across 43 files).

BareJS v0.2.11

Choose a tag to compare

@xarhang xarhang released this 03 Dec 07:09

What's New in BareJS v0.2.11

Core DX & Reliability

  • Scoped Request Cleanup (ctx.defer() & Symbol.asyncDispose / Symbol.dispose): LIFO, error-isolated cleanup callbacks on Context / EdgeContext (0 ns overhead when unused) + automatic disposal of derive() / macro().resolve() resources.
  • RFC 9457 Problem Details (ctx.problem()): Standard application/problem+json error responses with auto title/instance, extension fields, and CORS/cookie preservation across BareJS and BareEdge.
  • Plugin & Sub-App Deduplication: name + seed deduplication across BareRouter.use(), BareRouter.route(), and BareEdge.use().

6 Zero-Dependency Optional Subpaths (0 bytes in core/edge when unused)

  • barejs/mcp (11 KB): 1-line MCP 2025-03-26 Streamable HTTP server auto-generated from routes & schemas with in-memory app.fetch() execution.
  • barejs/devtools (8.4 KB): Live dark-mode Request Inspector (/__bare) with SSE waterfall, p50/p95/p99 latency profiler, redacted headers, SSRF-safe replay, and auto-disable in production.
  • barejs/queue (2.8 KB): Bounded concurrency, delayed jobs, exponential backoff retries, Dead-Letter Queue, graceful drain()/stop(), and compile-time typed job name & payload inference via chained .process() or createQueue<JobMap>().
  • barejs/webhooks (3.7 KB): Web Crypto HMAC-SHA256 verifyWebhook() with replay protection, key rotation, and retrying sendWebhook().
  • barejs/metrics (3.5 KB): Prometheus /metrics exporter with ID/UUID path normalization and custom counters/gauges.
  • barejs/ai (2.5 KB): Typed LLM SSE streaming (aiStream) with client-disconnect AbortSignal + parseOpenAISSE().

Verification

  • 532 tests / 7,044 assertions across 42 files passing + strict tsc --noEmit + docs drift check + clean-tarball consumer E2E.
  • Auto-published to npm with Sigstore Provenance via GitHub Actions OIDC Trusted Publishing.

BareJS v0.2.10

Choose a tag to compare

@xarhang xarhang released this 03 Dec 04:49

Security & Bug Fixes

  • Zero-dependency barejs/edge bundle (~35 KB, zero zod/@sinclair/typebox imports)
  • P0 cache() prePipeline ordering (never bypasses bareAuth/cors/rateLimit) & skips caching Set-Cookie/private/no-store
  • P0 Bun/uWS native route anti-shadowing for auth-protected routes
  • P0 uWS Tier 1 abort safety, Set-Cookie deduplication, and 400 Bad Request guard on malformed Host/URL across Node, uWS, and AWS Lambda
  • P1/P2 fixes across CSRF CIDR allowlist, tracing()/serverTiming(), jsx RAW_BRAND & nested <Suspense>, BareEdge plugins/headers/trailing-slash, compress() binary MIME filter, etag() 304 CORS retention, ctx.sse() cleanup, app.docs() prefix, group() WS merge, toSSG() traversal guard, and .d.ts fixes

Performance

  • Hot-path optimizations across Core, BareEdge, bareAuth HS256, rateLimit, cors, validators, etag (Bun.hash), cache, compress, and logger (+5% to +95% faster across production workloads)

Quality & CI

  • Added typecheck, test:docs, test:consumer (clean tarball + strict tsc --noEmit + live full-system E2E), upgraded CI to Node 22/24 & actions/*@v7, and enabled npm OIDC Trusted Publishing (520 tests / 6,963 assertions).

BareJS v0.2.9

Choose a tag to compare

@xarhang xarhang released this 01 Dec 10:20

Highlights

Bug Fixes (P0)

  • JIT app.derive() Multi-Route Cleanup: Fixed delete ctx[...] → delete rawCtx[...] in generated _rel(rawCtx, _uaf) helper for apps with 20+ routes.
  • app.macro() Inside app.group(): Fixed _createGroupRouter so grouped & nested routes inherit and enforce all registered macros.
  • Chainable app.setNotFound(): Now returns this for fluent chaining.

New Features

  • Meta Framework Integrations (prefix, .basePath(), safe app.fetch): Direct export const GET = app.fetch support for Next.js App Router, Astro, SvelteKit, Nuxt 3, Remix, and TanStack Start on both BareJS and BareEdge.
  • Official AI Agent Skill (skills/barejs/SKILL.md): Install via bunx skills add xarhang/bareJS / npx skills add xarhang/bareJS.
  • Verified: 511 tests / 6,918 assertions across 38 files passing in CI (Bun, Node.js 20 & 22, Deno 2).

BareJS v0.2.8

Choose a tag to compare

@xarhang xarhang released this 01 Dec 00:17

Highlights

  • Optional & Regex-Constrained Route Parameters: Registration-time expansion for :param? (0 ns runtime overhead) and inline JIT-compiled :id{[0-9]+} with fall-through to generic params.
  • Zero-Bloat Optional Subpaths (0 bytes in core/edge):
    • barejs/html (1.3 KB): XSS-safe html tagged template + raw() + escapeHtml().
    • barejs/etag (2.4 KB): Edge-safe dynamic etag() middleware (weak FNV-1a / strong SHA-256 + 304 Not Modified).
    • barejs/cache (2.2 KB): Edge-safe cache() middleware (Cache-Control, Vary, Web Cache API + custom CacheLike store).
    • barejs/jsx & barejs/jsx-runtime (4.5 KB): Zero-dep JSX/TSX SSR with async components & streaming <Suspense>.
    • barejs/ssg (2.1 KB): Build-time Static Site Generator (toSSG).
    • barejs/aws-lambda (3.0 KB), barejs/cloudflare-pages (768 B), barejs/netlify (752 B).
  • Examples & AI/SEO Discovery: Added examples/ starters, restructured README.md & llms.txt, auto-generated llms-full.txt, robots.txt, sitemap.xml, and JSON-LD.
  • Verified: 502 tests / 6,880 assertions across 37 files passing in CI (Bun, Node.js 20 & 22, Deno 2).

BareJS v0.2.7

Choose a tag to compare

@xarhang xarhang released this 30 Nov 09:39

What's New in v0.2.7

Added

  • Ergonomic file() 1-Liner Helper: app.get('/logo', () => file('public/logo.png')) with zero-copy Bun.file / Node streaming, optional root jail (blocks traversal & symlink escapes), null-byte rejection, and download header.
  • Generator Streaming (function* & async function*): Return sync or async generators directly for pull-based ReadableStream backpressure streaming (text, binary, NDJSON) with automatic gen.return() cleanup on client abort.
  • Declarative RouteSchemas.cookies Validation + OpenAPI 3.1: Fail-closed sync/async cookie validation & coercion with in: 'cookie' OpenAPI parameters.
  • Composable Plugin Macros (app.use(plugin)): Mounting a modular BareJS plugin inherits both routes and macros with full TypeScript inference.
  • Interactive Docs Site: Added cross-doc Ctrl+K / / Instant Search and sticky On This Page TOC on GitHub Pages.

Tests

  • 493 tests across 35 files (verified in CI across Bun, Node 20/22, and Deno 2).

BareJS v0.2.6

Choose a tag to compare

@xarhang xarhang released this 30 Nov 08:40

What's New in v0.2.6

Added

  • Per-Status Response Schemas (response: { 200, 400, 404 }): Per-status secret stripping, full OpenAPI 3.1 multi-status responses, and typed data / error unions in bareClient().safe and bareTreaty().
  • Strict Compile-Time bareTreaty Inference: Pure type-level TreatyTree<Routes> (0 runtime overhead) for bareTreaty(app) and bareTreaty<typeof app>(url).
  • Declarative Route app.macro(): beforeHandle + resolve with per-route TypeScript inference, automatic pool cleanup, and zero overhead on unused routes.
  • Fail-Closed WebSocket Schema Validation: Optional body, query, headers, and response schemas on app.ws() across Bun, Node.js, uWebSockets.js, Deno, and in-memory clients (zero overhead when omitted).
  • Zero-Dep W3C tracing() & serverTiming(): Edge-safe traceparent + Server-Timing middleware with onSpan hook.

Performance

  • 4x Smaller Edge Bundle: dist/edge.js shrunk from 201 KB → 50 KB (zero node:* imports).
  • O(1) Grouped Radix Dispatch: Replaced double switch in RadixNode.jitCompile() with a single Object.create(null) O(1) lookup table.
  • 7/7 Benchmark Sweep: Faster than ElysiaJS & Hono on all 7 CI scenarios (both mean and p99) under NODE_ENV=production.

Tests

  • 489 pass / 0 fail / 6,789 assertions across 35 files.

BareJS v0.2.5

Choose a tag to compare

@xarhang xarhang released this 30 Nov 06:18

What's New in v0.2.5

Added

  • Native TLS Support: Unified tls (ServeTlsOptions) in app.listen() & app.listenCluster() across Bun (Bun.serve({ tls })), Node.js uWebSockets.js (uWS.SSLApp), and Node.js https (node:https).
  • Zero-Node Edge Runtime (barejs/edge): Dedicated ./edge entrypoint (~195 KB, zero node:* imports) for Cloudflare Workers, Vercel Edge, and Deno Deploy.
  • Universal Standard Schema v1 (~standard): Native sync & async fail-closed validation for Valibot, ArkType, Zod 4, Effect, etc. across params, query, headers, body, and response.
  • Upgraded bareClient & bareTreaty: Non-throwing client.safe.* Result union, chained Proxy RPC (bareTreaty(app | url)), and typed WebSocket client (client.ws() / treaty.subscribe()) supporting both ws:// and in-memory BareJS.
  • GitHub Pages Documentation Site: Landing page & in-site Markdown docs reader at https://xarhang.github.io/bareJS/.

Security & Fixed

  • Stripped CR/LF (\r/\n) in Context.setHeader(), EdgeContext.setHeader(), EdgeContext.setCookie(), and EdgeContext.redirect() to prevent HTTP response splitting (zero-allocation fast path when clean).
  • EdgeContext.jsonBody() now returns 400 on malformed JSON instead of 500.
  • basicAuth() now sends RFC 7617 WWW-Authenticate: Basic realm="Restricted" on 401; added ctx.user setter and updated hasRole().

Tests

  • Added 7 new feature & security audit suites (483 tests / 6,740 assertions across 34 files).

BareJS v0.2.4

Choose a tag to compare

@xarhang xarhang released this 30 Nov 03:27

Fixed

  • uWebSockets.js Driver (src/runtime/uws.ts):
    • Copy ephemeral ArrayBuffer chunks in res.onData (Buffer.from(new Uint8Array(ab))) instead of creating a zero-copy view, fixing corrupted/empty bodies and crashes on chunked or TCP-fragmented POST/PUT/PATCH requests.
    • Skip content-length and transfer-encoding in writeUwsHeaders so uWebSockets.js manages framing headers cleanly when streaming ReadableStream responses (e.g. staticFile()).

BareJS v0.2.3

Choose a tag to compare

@xarhang xarhang released this 26 Nov 07:06

Adds uWS streaming backpressure & native WebSocket pub/sub, trustProxy CIDR allowlist, structured JSON useLog, onRequest/onResponse hooks, app.listenCluster(), staticFile SPA fallback, OpenAPI auto bearerAuth/basicAuth securitySchemes, and friendly EADDRINUSE errors. Verified across Bun, Node.js, and Deno (434 tests / 6,321 assertions).