JSRealm

A lightweight gateway programmable with JavaScript.

JSRealm lets you route requests, rewrite URLs, and proxy to backends using Web APIs you already know — fetch(), Request, Response, Headers. Write your gateway logic in JavaScript, get auto HTTPS with ACME, and scale to 300k+ req/sec on a single machine.

Single binary. Zero dependencies. Top-tier performance with top-tier usability.

var app = new App();

app.get('/hello/:name', (request, params) => {
    return new Response(`Hello, ${params.name}!`);
});

app.all('/api/*', (request) => {
    return fetch(request, {
        target: 'http://backend.internal:3000'
    });
});

export default app;

Features

  • HTTP/1.1 with keep-alive
  • HTTPS with automatic certificates (ACME/Let's Encrypt)
  • JavaScript support (ES2023)
  • Routing with path params and wildcards
  • fetch() for proxying requests
  • Authentication hooks
  • Response headers
  • Path rewrite
  • Gzip compression

Quick Start

# Download the latest release
wget https://github.com/lre66/jsrealm/releases/latest/download/jsrealm-linux-x86_64.tar.gz
tar xzf jsrealm-linux-x86_64.tar.gz

# Create app
mkdir myapp && cd myapp
echo '{"http": "0.0.0.0:8080"}' > config.json
cat > app.js << 'EOF'
var app = new App();
app.get('/', () => new Response('Hello, World!'));
export default app;
EOF

# Run
../jsrealm

# Test
curl http://localhost:8080/