Docs/Overview

Deploying Node.js & Express APIs

Host Express, Fastify, NestJS, or native Node.js HTTP servers on Exovon Compute in Mumbai (asia-south1). Benefit from automated HTTPS certificates, DDoS mitigation, horizontal autoscaling, and zero-configuration containerization.

Automated Containerization

Exovon detects your start script and synthesizes a minimal, hardened Linux microcontainer without requiring custom Dockerfiles.

Scale-to-Zero Efficiency

Idle APIs hibernate after 15 minutes of inactivity, waking back up in sub-250ms when incoming traffic arrives.

Automated Health Probing

Edge routing canary probes verify HTTP 200 responses before shifting live traffic to eliminate broken releases.

1. Production Express Server Template

Your server process must bind to the port defined by process.env.PORT (defaulting to 8080) and listen on the universal address "0.0.0.0":

server.js
const express = require('express');
const app = express();

app.use(express.json());

// 1. Health check endpoint (Required for canary verification)
app.get('/health', (req, res) => {
  res.status(200).json({ status: 'healthy', timestamp: Date.now() });
});

// 2. API route
app.get('/api/v1/data', (req, res) => {
  res.json({ message: 'Hello from Exovon Compute Mumbai!' });
});

// 3. Bind to PORT on 0.0.0.0 (NOT 127.0.0.1)
const PORT = process.env.PORT || 8080;
const HOST = '0.0.0.0';

const server = app.listen(PORT, HOST, () => {
  console.log(`Server running on http://${HOST}:${PORT}`);
});

// 4. Graceful shutdown handler
process.on('SIGTERM', () => {
  console.log('SIGTERM received, closing HTTP server gracefully...');
  server.close(() => process.exit(0));
});
Host Binding Requirement: Do not bind your server exclusively to 127.0.0.1 or localhost. Inside a Linux container, 127.0.0.1 only listens to internal loopback traffic, preventing the edge proxy from forwarding traffic and returning a 502 Bad Gateway error.

2. Package Configuration

Ensure your package.json defines a valid "start" script. For TypeScript projects, specify a "build" script:

package.json
{
  "name": "my-api-server",
  "version": "1.0.0",
  "main": "dist/index.js",
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}

3. Deploy via Exovon CLI

Deploy your backend service directly from your local terminal:

Terminal
# 1. Authenticate with your Exovon account
npx exovon login

# 2. Link directory to your project
npx exovon link --project my-api-server

# 3. Add production environment variables securely
npx exovon env add JWT_SECRET "$(openssl rand -hex 32)"

# 4. Deploy containerized Node.js API to Mumbai edge
npx exovon deploy --dynamic

Frequently Asked Questions

Can I deploy WebSocket servers with Node.js on Exovon?

Yes. Exovon Compute supports persistent WebSocket connections with HTTP Upgrade headers, allowing you to run Socket.io and native ws servers.

How do I install native C++ npm packages like sharp or bcrypt?

Exovon build environments run on Debian Linux with standard build toolchains pre-installed, ensuring node-gyp native compilation succeeds out of the box.

Was this documentation page helpful?