Node.js Applications

Deploy scalable Node.js APIs and backend services with automatic builds, monitoring, and zero-downtime deployments.

Overview

RunxBuild runs your Node.js application in an isolated environment. Your service must listen on the port provided via the PORT environment variable.

Files RunxBuild Looks For

Ensure your repository contains a package.json in the configured root directory. Lockfiles are recommended for reproducible installs.

package.json:

{
  "name": "runxbuild-node-service",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "start": "node index.js"
  },
  "dependencies": {
    "dotenv": "^17.3.1"
  }
}

Basic Express Template

Below is a minimal Express server example:

const http = require("http");
const dotenv = require("dotenv");
dotenv.config();

const PORT = process.env.PORT || 8080;

const server = http.createServer((req, res) => {
  if (req.method === "GET" && req.url === "/") {
    res.writeHead(200, { "Content-Type": "application/json" });
    res.end(JSON.stringify({ message: "RunxBuild Node.js service running" }));
    return;
  }

  res.writeHead(404, { "Content-Type": "application/json" });
  res.end(JSON.stringify({ error: "Not found" }));
});

server.listen(PORT, "0.0.0.0", () => {
  console.log('Server running on port', PORT);
});

// Graceful shutdown
process.on("SIGTERM", () => {
  console.log("SIGTERM received, shutting down...");
  server.close(() => process.exit(0));
});

Monorepos & Root Directory

If your Node app lives in a subfolder (for example /apps/api), configure your service root directory to that folder so the build system can find your package.json and lockfile.

Deployment Settings

When creating your Web Service on RunxBuild, use the following configuration:

  • Build Command: npm install
  • Output Directory: (leave empty)
  • Start Command: npm start

Dependencies are installed automatically. Your service starts using the provided start command.