Skip to content

Express-compatible API on Velociradix ​

velociradix/express gives you the Express application shape (app.use, Router, req/res/next, express.json(), …) while Velociradix’s C++ engine owns the socket, HTTP parse, and response bytes.

text
Your Express-style code  →  velociradix/express stack  →  Velociradix C++ core

Install & hello world ​

bash
npm install velociradix
js
import express from "velociradix/express";
import morgan from "morgan";

const app = express();

app.use(morgan("dev"));
app.use(express.json());

app.get("/", (req, res) => {
  res.json({ engine: "velociradix", path: req.path });
});

app.post("/echo", (req, res) => {
  res.status(201).json({ body: req.body });
});

const api = express.Router();
api.get("/users/:id", (req, res) => {
  res.json({ id: req.params.id, base: req.baseUrl });
});
app.use("/api", api);

app.listen(3000);

Same import style as Express:

js
import express, {
  Router,
  json,
  urlencoded,
  static as serveStatic,
} from "velociradix/express";

What matches Express ​

AreaBehavior
app.use / Router.useMiddleware stack order, path mounts, baseUrl stripping
app.get/post/...Route verbs, :params, req.params / req.query
app.route(path).get().post()Chained route
express.json / urlencoded / text / rawBody parsers (from buffered native body)
express.staticStatic files with fallthrough
res.status().json().send().end()Fluent response API
res.on('finish')Works with morgan, response-time, etc.
Error middleware(err, req, res, next) — arity 4
Settingsapp.set / get / enable / disable

What is not Node/Express internals ​

  • Not the npm express package.
  • req / res are bridges, not http.IncomingMessage / ServerResponse.
  • Middleware that needs raw TCP streams, half-open sockets, or Express private fields may fail.
  • res.render needs a view host you wire yourself (stub throws).
  • HTTP parsing is still Velociradix’s custom C++ parser (not llhttp). See Trust.

Marketing line (honest) ​

Write Express. Run Velociradix.

Use this package when you want Express ergonomics and the Velociradix engine. Use core velociradix + useExpress(morgan()) when you prefer the native (ctx, next) API.

Core bridge (optional) ​

Without the Express subpath, the same bridge exists on the core app:

js
import { createApp } from "velociradix";
import morgan from "morgan";

const app = createApp();
app.use(morgan("dev")); // arity-3 → Express bridge
app.get("/", (ctx) => ctx.json({ ok: true }));
app.listen(3000);

Released under the MIT License.