npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@velox0/cerver

v0.5.0

Published

Compile restricted JavaScript server logic into optimized native C binaries

Downloads

1,168

Readme

Cerver

Publish CI npm

A lightweight, compile-time web framework that transpiles restricted JavaScript server logic into highly optimized native C HTTP server binaries.

Cerver takes a Next.js-style file-based routing structure (written in a strict subset of JavaScript), parses it, generates equivalent C code, embeds your static assets, and compiles it all into a single, standalone executable that runs with zero Node.js dependency.

Features

  • Compile-Time Framework: Your JavaScript is parsed and compiled to native C. There is no JavaScript engine (like V8) or interpreter included in the final binary.
  • Microscopic Footprint: Generated executables are tiny and start in milliseconds.
  • Single-Binary Deployment: Static assets (HTML, CSS, JS, images) are automatically minified and embedded directly into the executable as C byte arrays.
  • Native Performance: Uses kqueue (macOS) or epoll (Linux) event loops for high-performance non-blocking I/O.
  • File-Based Routing: Intuitive routes/ directory structure, supporting dynamic segments (e.g., /item/[id].js).

Benchmarks (Autocannon)

Local loopback runs against localhost, 20s per run.

Note: timeouts only appear at the highest concurrency (240 connections). On a single machine, autocannon and the server compete for CPU and kernel resources; the timeouts are likely client/loopback saturation rather than server errors.

| Connections | Pipelining | Avg req/s | Avg latency | p99 latency | Total read | Errors (timeouts) | | ----------- | ---------- | --------- | ----------- | ----------- | ---------- | ----------------- | | 60 | 1 | 123,005 | 0.01 ms | 0 ms | 21.0 GB | 0 | | 60 | 10 | 125,973 | 4.26 ms | 10 ms | 21.5 GB | 0 | | 120 | 1 | 124,214 | 0.15 ms | 1 ms | 21.2 GB | 0 | | 120 | 10 | 131,245 | 8.64 ms | 15 ms | 22.4 GB | 0 | | 240 | 1 | 124,890 | 0.54 ms | 1 ms | 21.3 GB | 118 (timeout) | | 240 | 10 | 123,677 | 9.87 ms | 14 ms | 21.1 GB | 1540 (timeout) |

Getting Started

  1. Install globally (requires gcc or clang on your system):
npm i @velox0/cerver@latest
  1. Create a new project:
cerver new my-fast-api
cd my-fast-api
  1. Build and Run:
cerver build
cerver run

Routing

Routes are defined in the routes/ directory.

routes/index.js (maps to /)

export function GET(req, res) {
  return res.html(200, "<h1>Hello World!</h1>");
}

routes/api/status.js (maps to /api/status)

export function GET(req, res) {
  return res.json(200, '{"status": "online"}');
}

routes/users/[id].js (maps to /users/:id)

export function GET(req, res) {
  const userId = req.params.id;
  return res.text(200, "User ID: " + userId);
}

Clean URL Asset Mapping

Cerver has a special asset routing convention that prevents folder clutter:

  • Root Index: public/index.html is automatically served at the root /.
  • Directory Indexing: Nested index.html files inside directories (e.g. public/page/index.html) are not implicitly aliased to /page (they remain at /page/index.html).
  • Clean Folder Slugs: If an HTML file has the exact same name as its parent directory, it is mapped to the clean directory URL. For example:
    • public/about/about.html maps to /about (and /about/)
    • public/blog/posts/posts.html maps to /blog/posts (and /blog/posts/)
  • Other Static Assets: All other assets like CSS, JS, images, and non-directory-matching HTML files serve directly at their file paths (e.g., public/about/style.css maps to /about/style.css).

The Request & Response Objects

Because Cerver compiles to C, the API surface is restricted.

Request (req)

  • req.path — The request URL path
  • req.method — The HTTP method
  • req.headers["user-agent"] — Access request headers
  • req.query.search — Access URL query parameters
  • req.params.id — Access dynamic path segments

Response (res)

  • res.text(status, string) — Send plain text
  • res.json(status, string) — Send JSON
  • res.html(status, string) — Send HTML

Supported JavaScript

Cerver supports a strict, synchronous subset of JavaScript suitable for C code generation:

  • if/else statements
  • const / let variable declarations
  • String and Number literals
  • Template literals
  • Basic comparisons (===, !==, <, >)

Not Supported (Compile-Time Errors):

  • async/await and Promises
  • Loops (for, while)
  • Classes and the new keyword
  • eval()
  • Runtime import/require

Configuration

cerver.config.js:

export default {
  port: 8080, // Default port
  embed: true, // Embed assets from public/ into the binary
  minify: true, // Minify HTML/CSS/JS before embedding
  compression: "none", // Future: pre-compress assets
};

How It Works

  1. Parser: Uses Acorn to parse your JS route files into ASTs.
  2. Validator: Scans the AST to ensure no unsupported JS features are used.
  3. IR: Transforms the AST into an Intermediate Representation.
  4. Generator: Emits optimized C code mapping directly to your JS logic.
  5. Asset Pipeline: Scans the public/ folder, minifies files, and converts them to C byte arrays.
  6. Compiler: Invokes gcc or clang to compile the generated code and the Cerver runtime into a native binary.