Getting Started
Install the latest release from npm:
bash
npm install velociradixNode.js ≥ 20. Prebuilds for Linux x64, macOS arm64, Windows x64; otherwise make compiles the addon.
This is a native .node module with a custom HTTP parser (not llhttp). Read Trust before listen on 0.0.0.0. Version policy: versioning.
Basic server
js
import { createApp, helmet } from "velociradix";
const app = createApp();
app.use(helmet());
// Public API from a browser origin:
// helmet({ contentSecurityPolicy: false, crossOriginResourcePolicy: "cross-origin" })
app.fastGet("/health", { ok: true });
app.get("/", (ctx) => {
return { message: "Hello from Velociradix" };
});
app.get("/users/:id", (ctx) => {
return { userId: ctx.params.id, search: ctx.query("q") };
});
app.listen(3000, () => {
console.log("http://localhost:3000");
});fastGet is C++ static output (no JS per request). app.get is your application. They are not the same speed class — benchmarks.
Scaffold: npx create-velociradix-app my-api
TypeScript
ts
import { createApp, type Context, BadRequestError } from "velociradix";
interface UserProfile {
id: number;
name: string;
}
const app = createApp();
app.get("/users/:id", async (ctx: Context) => {
const id = Number(ctx.params.id);
if (!Number.isFinite(id)) {
throw new BadRequestError("Invalid User ID");
}
const user: UserProfile = { id, name: "Moaaz" };
return ctx.json(user);
});
app.listen(3000);Optional imports
| Need | Import |
|---|---|
| HTTP client | velociradix/client |
| Express middleware shim | velociradix/express |
| Decorators | velociradix/decorators |
These are extras. The engine does not require them.