barejs 0.1.62 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/index.js +149 -149
- package/dist/node.js +149 -149
- package/dist/types/core/bare.d.ts +3 -0
- package/dist/types/runtime/types.d.ts +3 -0
- package/dist/types/runtime/uws.d.ts +13 -0
- package/llms.txt +1 -1
- package/package.json +1 -1
- package/src/core/bare.ts +224 -1
- package/src/runtime/bun.ts +3 -0
- package/src/runtime/node.ts +10 -0
- package/src/runtime/types.ts +3 -0
- package/src/runtime/uws.ts +554 -0
package/README.md
CHANGED
|
@@ -37,12 +37,12 @@ app.listen(3000);
|
|
|
37
37
|
|
|
38
38
|
## Why BareJS?
|
|
39
39
|
|
|
40
|
-
- **O(1) JIT Router,
|
|
40
|
+
- **O(1) JIT Router, Bun Native Routes & Pooling:** Compiles static routes into an inline `switch` fast-path and dynamic routes into a radix jump-table (`:params`, `*` wildcards, `BareRouter` sub-app mounting) with a lazy LIFO `Context` pool (`0..65536`) and dev-mode Use-After-Free Proxy guard. On Bun, `app.listen()` also offloads eligible middleware-free routes to `Bun.serve({ routes })` (with pure-static `Response` and `isTrulyZeroArg` fast-paths in `NODE_ENV=production`) while keeping full `fetch()` fallback parity.
|
|
41
41
|
- **Unified Schema Validation:** Declarative `body`, `query`, `params`, `headers`, and `response` schemas with **TypeBox**, **Zod**, or **Native JSON Schema** — including auto-coercion, `stripUnknown` Mass-Assignment protection, `413` `maxBodySize` guards, and automatic secret-field stripping.
|
|
42
42
|
- **End-to-End Type Safety:** `bareClient(app)` provides compile-time route, param, query, body, and response inference over HTTP or zero-network in-memory calls.
|
|
43
43
|
- **Batteries Included:** Auto-generated **OpenAPI 3.1** + Scalar UI (`app.docs`), **JSON-RPC 2.0** (`app.rpc`), **WebSockets** (`app.ws`), **SSE** (`ctx.sse`), **Streaming Uploads** (`ctx.upload` / `ctx.uploadStream`), **Compression** (`compress` — `zstd`/`br`/`gzip`), **Static Files** (`staticFile` with ETag/`304`/Range `206`), `app.derive`, `app.cron`, `logger`, and `healthcheck`.
|
|
44
44
|
- **Zero-Trust Security & Resilience:** Built-in `bareAuth` (HS256/RS256/ES256/JWKS + `revokeToken`), `basicAuth`, `hasRole`, `Hash` (Argon2id/bcrypt/scrypt), HMAC-signed cookies, `cors`, `csrf`, `rateLimit`, `idempotency`, `circuitBreaker`, `createSingleflight`, `timeout`, `redisStore`, and `app.onDrain`.
|
|
45
|
-
- **Multi-Runtime & Web Standard Interop:** Zero-dep native drivers for **Bun
|
|
45
|
+
- **Multi-Runtime & Web Standard Interop:** Zero-dep native drivers for **Bun** (`Bun.serve({ routes })`), **Node.js >= 20** (`barejs/node` with built-in RFC 6455 WebSockets & `scrypt`, plus optional `uWebSockets.js` auto-detection or `{ engine: 'uws' }`), and **Deno >= 2.0** (`Deno.upgradeWebSocket`). Standard `Request`/`Response` (`ctx.req`) works directly with **Better-Auth**, **Auth0**, **Clerk**, **GraphQL Yoga**, **Sentry**, and **OpenTelemetry**.
|
|
46
46
|
|
|
47
47
|
---
|
|
48
48
|
|
|
@@ -126,12 +126,12 @@ Measured in-process on **Bun** with [`mitata`](https://github.com/evanwash/mitat
|
|
|
126
126
|
|
|
127
127
|
| Scenario | **BareJS** | **ElysiaJS** | **Hono** |
|
|
128
128
|
| :--- | :---: | :---: | :---: |
|
|
129
|
-
| **1. 100 Routes + Dynamic Params** | **`
|
|
130
|
-
| **2. 10 Middlewares + Deep Path** | **`1.
|
|
131
|
-
| **3. POST JSON + Schema Validation** |
|
|
132
|
-
| **4. Async Handler + Query Parsing** |
|
|
129
|
+
| **1. 100 Routes + Dynamic Params** | **`1.47 µs`**<br><sub>`p99: 8.16 µs`</sub> | `1.94 µs`<br><sub>`p99: 8.89 µs`</sub> | `3.83 µs`<br><sub>`p99: 14.60 µs`</sub> |
|
|
130
|
+
| **2. 10 Middlewares + Deep Path** | **`1.44 µs`**<br><sub>`p99: 7.16 µs`</sub> | `1.98 µs`<br><sub>`p99: 8.89 µs`</sub> | `4.11 µs`<br><sub>`p99: 14.88 µs`</sub> |
|
|
131
|
+
| **3. POST JSON + Schema Validation** | `4.18 µs`<br><sub>`p99: 14.68 µs`</sub> | `4.54 µs`<br><sub>`p99: 14.16 µs`</sub> | `4.58 µs`<br><sub>`p99: 15.66 µs`</sub> |
|
|
132
|
+
| **4. Async Handler + Query Parsing** | **`2.00 µs`**<br><sub>`p99: 8.61 µs`</sub> | `2.30 µs`<br><sub>`p99: 9.53 µs`</sub> | `3.20 µs`<br><sub>`p99: 12.85 µs`</sub> |
|
|
133
133
|
|
|
134
|
-
> Last Updated: 2026-11-25 (github action — `linux`, AMD EPYC
|
|
134
|
+
> Last Updated: 2026-11-25 (github action — `linux`, AMD EPYC 7763 64-Core Processor, Bun `1.4.5`, Elysia `1.4.21`, Hono `4.11.4`)
|
|
135
135
|
|
|
136
136
|
<!-- MARKER: MULTI_BENCH_SUMMARY_END -->
|
|
137
137
|
|