Skip to content

Fast-path C++ static routes ​

fastGet, fastPost, and fastRoute serve a preformatted JSON or text body from C++. The Node.js event loop is not used for those requests.

That is why they are fast. That is also why they are not comparable to Fastify or app.get.

Measured with the same autocannon settings as the JS-handler table: about 114k req/s on Apple Silicon. Older copy that said 350,000+ was not this test — do not use it.

Use fast-path for /health, /ping, and other payloads that do not change per request. Anything that reads ctx, middleware, or a database belongs on app.get.


Examples ​

js
import { createApp } from "velociradix";

const app = createApp();

app.fastGet("/health", { status: "ok" });
app.fastGet("/ping", "pong");
app.fastPost("/webhook/ack", { received: true });
app.fastRoute("GET", "/api/v1/config", { env: "production" }, 200, {
  "Cache-Control": "public, max-age=3600",
});

app.listen(3000);

Honest numbers: benchmarks.

Released under the MIT License.