Skip to content

Features โ€‹

The product is the C++ HTTP engine plus app.get / middleware / ctx. Everything below that is optional.

Core (this is what you are installing): native workers, radix router, JS handlers, fastGet for static bodies, helmet / cors / JWT helpers, SSE, static files with root in production.

Extras (exist, not the pitch): Express shim, client SDK, decorators, EventBus, file-based routing, Swagger/Postman UI, mock server, GraphQL helper (experimental). Use them if you need them. Do not treat โ€œ60 featuresโ€ as a reason to trust the parser.

Parser and production constraints: Trust.


โšก Core Engine Architecture โ€‹

ComponentTechnical ImplementationBenefit
Event Multiplexerkqueue (macOS/BSD), epoll (Linux), IOCP (Windows)Non-blocking event-driven network I/O with $O(1)$ event notifications.
Radix Trie RouterPure C++17 Radix Tree$O(K)$ parameter and wildcard route lookup regardless of route count.
Object PoolingV8 Monomorphic Shape PoolsZero Garbage Collection shape churn on Context and Request wrappers.
Response Tail CachingShared 1-Second Format BuffersEliminates redundant string allocations for Date, Server, and Connection.
Fast-Path EnginefastGet, fastPost, fastRouteBypasses V8 execution entirely to serve static JSON/text directly from C++ memory.
HTTP ParserRFC 7230 tchar + smuggling guardsRejects TE+CL, duplicate Content-Length, obs-fold, TRACE; 32 KiB header cap.
Socket TuningTCP_NODELAY, Linux accept4Immediate small-response flush; one-syscall accept on Linux.

๐Ÿ”€ 1. Multi-Version API Router (app.versioning()) โ€‹

Seamlessly handle multiple API versions via headers (e.g. X-API-Version: v2) or path prefixes (/v1, /v2):

javascript
app.versioning(
  {
    v1: appV1,
    v2: appV2,
  },
  { headerName: "x-api-version" },
);

๐Ÿ“ก 2. Type-Safe JSON-RPC 2.0 Engine (app.rpc()) โ€‹

Registers lightweight JSON-RPC endpoints for direct frontend-to-backend procedure execution:

javascript
app.rpc("/rpc", {
  multiply: ({ a, b }) => a * b,
  getUser: ({ id }, ctx) => ({ id, name: "Alice" }),
});

๐Ÿ“Š 3. Terminal CLI Route Printer (app.printRoutes()) โ€‹

Prints a clean, formatted ASCII route table to the terminal showing all registered methods and endpoints:

javascript
app.printRoutes();

โณ 4. Automated Periodic SSE Ticker (ctx.sseInterval()) โ€‹

Streams periodic real-time Server-Sent Events at configured time intervals:

javascript
app.get("/live-prices", (ctx) => {
  return ctx.sseInterval(() => ({ price: Math.random() * 100 }), 1000);
});

๐Ÿ” 5. Granular Dynamic Rate Limiter (rateLimitByKey()) โ€‹

Restricts request rate dynamically based on custom keys (e.g. User ID, API Key, Tenant ID):

javascript
import { rateLimitByKey } from "velociradix";

app.use(
  rateLimitByKey({
    max: 100,
    windowMs: 60000,
    keyFn: (ctx) => ctx.get("x-api-key") || ctx.ip,
  }),
);

๐Ÿ“ 6. File-System Based Auto Routing (app.autoRoute()) โ€‹

Automatically scans routes directories recursively and maps exported route functions (GET, POST, PUT, DELETE, etc.) or default handlers to HTTP paths:

javascript
// Scans ./routes directory recursively
app.autoRoute("./routes");

๐Ÿ”Œ 7. WebSockets โ€‹

app.ws() was removed in 8.2.0. It never performed a 101 Switching Protocols upgrade or framed WebSocket messages. Use a dedicated WebSocket library (with Origin checks) if you need a real WebSocket.


๐Ÿ”ฎ 8. Experimental GraphQL helper (app.graphql()) โ€‹

POST-only toy resolver (8 KiB query cap). Not a GraphQL server โ€” no depth/cost limits.

javascript
app.graphql("/graphql", `type Query { user(id: ID!): User }`, {
  user: (ctx) => ({ id: ctx.params.id || 1, name: "Alice", role: "admin" }),
});

๐Ÿ“ก 9. Multi-Channel SSE Broadcast (app.sseBroadcast()) โ€‹

Stream named events to connected clients across specific broadcast channels:

javascript
// Broadcast to all clients subscribed to 'live-feed'
app.sseBroadcast("live-feed", { timestamp: Date.now(), activeUsers: 142 });

๐Ÿ›ก๏ธ 10. Circuit Breaker Resiliency Middleware (circuitBreaker()) โ€‹

Protects external database or microservice endpoints with failure threshold monitoring and state transition (Closed, Open, Half-Open):

javascript
import { circuitBreaker } from "velociradix";

app.use(circuitBreaker({ failureThreshold: 5, resetTimeoutMs: 10000 }));

๐ŸŽญ 11. Built-in API Mocking Engine (app.mockServer()) โ€‹

Registers mock endpoints with simulated latency delay for frontend integration:

javascript
app.mockServer({
  "GET /api/users": {
    status: 200,
    delayMs: 100,
    body: [{ id: 1, name: "Alice" }],
  },
  "POST /api/orders": { status: 201, delayMs: 200, body: { orderId: 99 } },
});

โฑ๏ธ 12. Fluent HTTP Cache-Control Helper (ctx.cacheControl()) โ€‹

Expressive helper for max-age, s-maxage, stale-while-revalidate, public, private, and immutable headers:

javascript
app.get("/assets/logo.png", (ctx) => {
  ctx.cacheControl({ maxAge: 3600, public: true, staleWhileRevalidate: 86400 });
  return ctx.sendFile("./public/logo.png");
});

โšก 13. Programmatic Load Tester & Benchmark Runner (app.bench()) โ€‹

Runs local throughput (RPS) and latency benchmarking:

javascript
const stats = await app.bench({ iterations: 1000, path: "/api/users" });
console.log(`RPS: ${stats.rps} req/sec | Total Time: ${stats.totalMs} ms`);

๐Ÿง  14. Dynamic Auto-Scaling Worker Threads (app.autoScale()) โ€‹

Dynamically adjusts native C++ worker thread pool allocation based on system heap memory and load:

javascript
app.autoScale({ minWorkers: 2, maxWorkers: 8, intervalMs: 5000 });

Released under the MIT License.