Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

1. Create and deploy a Node.js and Express hello app

You will see a hello response at / and ok at /health before adding any services.

1. Download and run locally

Download the hello ZIP into a working directory, then open a terminal in that directory:

unzip nodejs-hello.zip
cd nodejs-hello
npm ci
npm start

Keep it running. In another terminal, curl -fsS http://localhost:3000/health should print ok. Open http://localhost:3000/ and confirm the hello message. Stop the server with Ctrl+C.

The app source is small enough to inspect in full:

package.json

{
  "name": "d2o-hello",
  "private": true,
  "type": "module",
  "engines": {
    "node": "22.x"
  },
  "scripts": {
    "start": "node server.mjs"
  }
}

server.mjs

import { createServer } from 'node:http';
const server = createServer((req, res) => {
  res.setHeader('Content-Type', 'text/plain');
  res.end(req.url === '/health' ? 'ok\n' : 'Hello from Node.js on d2o!\n');
});
server.listen(Number(process.env.PORT || 3000), '0.0.0.0');
process.on('SIGTERM', () => server.close());

Procfile

web: npm start

Keep the supplied lockfiles in Git. The buildpack uses these manifests and its runtime version declaration to reproduce the app’s dependencies.

2. Create the Environment

Dashboard: open Project Examples → create Environment nodejs, type Development, branch main, release source Build, Automatic deployment on.

CLI:

paas envs create nodejs -o "$TUTORIAL_ORG" -p examples --type development --branch main --release-source build

3. Create the web app

Dashboard: inside nodejs choose Add Resource → Web Application. Name it notes-web, choose Framework Node.js, Repository The environment’s shared repository, Directory blank (repository root), and Process type web. Use Port 3000, Health Check Path /health, and one replica. Click Create Resource.

CLI:

paas apps create notes-web --framework nodejs --shared-source --start-command web --port 3000 --health-check-path /health -o "$TUTORIAL_ORG" -p examples -e nodejs

4. Commit and push

Initialize a repository in the unpacked hello directory:

git init -b main
git add .
git commit -m "Add hello application"

Dashboard path: open the Environment’s Git remote panel, copy its shared-repository remote command into this directory, then run its push command. This is the Environment remote, not a per-app remote. The dashboard supplies the correct host and authentication URL.

CLI path: omit -a when setting the shared remote:

paas git remote -o "$TUTORIAL_ORG" -p examples -e nodejs
git push d2o main
paas watch -a notes-web -o "$TUTORIAL_ORG" -p examples -e nodejs

5. Verify the deployed app

Dashboard: open notes-web → Deployments, wait for the successful build and running instance, then open its public URL. Append /health; it should display ok. CLI: paas ps and paas logs with -o "$TUTORIAL_ORG" -p examples -e nodejs and -a notes-web show the running process. Use the public URL displayed in the dashboard, or read the url field from paas apps info notes-web --json with the same Organization, Project, and Environment flags.

APP_URL=https://your-app-host
curl -fsS "$APP_URL/health"
curl -fsS "$APP_URL/"

Set APP_URL to your actual URL, with no trailing slash. If the build fails, see troubleshooting before continuing.

Next: Persist notes in PostgreSQL.