All guides

Node.js · Express

With a package.json, it runs npm start.

  1. 1App

    The platform sets the PORT environment variable (default 8080). Listen on 0.0.0.0:$PORT.

    js
    const express = require("express");
    const app = express();
    app.get("/", (req, res) => res.send("Hello OneCloud"));
    app.get("/healthz", (req, res) => res.send("ok"));
    app.listen(process.env.PORT || 8080, "0.0.0.0");
  2. 2package.json

    Runs the start script; otherwise server.js, then index.js. pnpm or yarn lockfiles switch the installer.

    json
    {
      "name": "api",
      "scripts": { "start": "node server.js" },
      "dependencies": { "express": "^4.21.0" }
    }
  3. 3Deploy (pick one)

    ① Connect GitHub: Project → Add service → GitHub repository (deploys on push) ② From this folder: oc up --wait (builds even without a Dockerfile) ③ Upload a folder or zip in the console: Add service → Upload source

    bash
    oc login
    oc project create my-app --link
    oc up --wait
  4. 4Health check (zero-downtime)

    Set the health check path to /healthz; traffic moves only when the new version returns 200.

Related guides