Skip to content

About

A ready-to-use Express.js starter for building Node.js APIs and web applications, configured for deployment on Cloudways.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Express sample app on Cloudways Velocity

Deploy a sample Express.js app on Cloudways Velocity — managed Node.js hosting with NGINX, PM2, SSL, and Git-based deploys.

Velocity is built for Node.js frameworks, so you do not need Apache mod_proxy, .htaccess rewrites, or manual SSH/PM2 setup used on classic Cloudways Flexible servers.

This repository is a starter template from Cloudways. Use it as a sample, then replace routes and views with your own application.

What’s in this repo

File / folder Purpose
server.js App entry point (listens on port 3000 — Velocity’s app port)
src/ Express app, routes (/, /api, /health), middleware
public/ Cloudways-branded sample home page and static assets
package.json Dependencies and npm start / npm run dev scripts
package-lock.json Locks dependency versions for reproducible deploys
.env.example Example environment variables for local runs
ecosystem.config.cjs Optional PM2 config for local / non-Velocity hosts

Build and start commands used by Velocity:

npm install   # install dependencies (or use Velocity’s built-in install)
npm start     # → node server.js

There is no compile/bundle step. If Velocity already runs npm install before your build command, you can leave Build empty in the dashboard; either approach is fine.

Prerequisites

  • A Cloudways account with Velocity access
  • This repository pushed to GitHub (or another Git provider Velocity can connect to)
  • A domain (optional at first; Velocity provides a default URL)
  • Node.js 18.x+ (22.x or 24.x LTS recommended; selectable per app in Velocity)

Quick start (local)

git clone https://github.com/YOUR_USERNAME/cloudways-sample-express-app.git
cd cloudways-sample-express-app
cp .env.example .env
npm install
npm run dev

Open http://127.0.0.1:3000.

Endpoint Description
GET / Cloudways-branded sample home page
GET /api API metadata (JSON)
GET /health Health check (uptime)

1. Push this repository

If you forked or cloned this repo locally:

git clone https://github.com/YOUR_USERNAME/cloudways-sample-express-app.git
cd cloudways-sample-express-app
git remote -v   # confirm origin points at your GitHub repo
git push -u origin main

Velocity deploys from Git — keep package.json and package-lock.json on the branch you will connect (usually main).

2. Create a Velocity application

  1. Open the Cloudways platform and go to Velocity.
  2. Click Get Started / create a new application.
  3. Connect your Git provider and select this repository.
  4. Choose branch main (or your deploy branch).
  5. Set framework to Express (or Custom / Node.js if Express is not listed).
  6. Select Node.js 22.x or 24.x (or another LTS your app supports).
  7. Confirm build and start commands:
    • Build: npm install (or leave empty if Velocity already installs deps)
    • Start: npm start
  8. Pick a plan size and deploy.

Velocity handles NGINX reverse proxy, PM2 process management, OS patching, and SSL for the default hostname. Your app only needs to listen on port 3000.

3. Configure environment variables

In the Velocity app settings, add environment variables as needed.

Variable Default Notes
NODE_ENV production Use production on Velocity
PORT 3000 Must stay 3000 on Velocity
HOST 127.0.0.1 Bind locally; NGINX proxies public traffic
APP_NAME Cloudways Express Sample App Shown in /api responses

Redeploy or restart the app after changing variables so the process picks them up.

4. Custom domain and SSL

  1. In Velocity, open your application → Domains (or equivalent).
  2. Add your domain / subdomain.
  3. Point DNS (A/CNAME) as instructed by Cloudways.
  4. Wait for SSL provisioning.
  5. Open https://your-domain/ and confirm the sample home page loads.

5. Verify the install

  1. Open the Velocity app URL (or your custom domain).
  2. Confirm the Cloudways-branded sample page at /.
  3. Check https://your-app-url/health returns JSON with "status":"ok".
  4. Check https://your-app-url/api for API metadata.
  5. In Velocity logs, confirm the process is running and listening on port 3000.

Updating the app

  1. Change code locally (routes, views, dependencies).

  2. Commit and push to the connected branch:

    git add .
    git commit -m "Describe your change"
    git push
  3. Let Velocity auto-deploy from Git, or trigger a manual redeploy in the dashboard.

Project structure

.
├── server.js              # Entry point
├── package.json           # Scripts and dependencies
├── .env.example           # Local env template
├── ecosystem.config.cjs   # Optional PM2 (non-Velocity)
├── public/                # Sample home page + static assets
└── src/
    ├── app.js             # Express app setup
    ├── config/            # Environment config
    ├── middleware/        # Error handling
    └── routes/            # Route handlers

Customization

  1. Add routes in src/routes/.
  2. Register them in src/routes/index.js.
  3. Add middleware in src/app.js.
  4. Replace public/index.html with your own UI (or serve an API-only app).
  5. Update APP_NAME via Velocity env vars or .env locally.

Deploy elsewhere

This template also runs on other Node hosts. Set PORT from the platform and run npm start.

For platforms that require binding to all interfaces:

HOST=0.0.0.0
PORT=3000

On non-Velocity hosts you may manage the process yourself (for example with the included ecosystem.config.cjs and PM2).

Troubleshooting

Symptom What to check
App won’t start Velocity build/start logs; Node version ≥ 18; npm install succeeds
Blank page / 502 Process must listen on 3000; confirm start command is npm start
Wrong env values Set variables in the Velocity dashboard and redeploy/restart
Static assets 404 Confirm public/ is in the repo and deployed with the app
Out of memory Upgrade Velocity plan (more RAM)

Useful links

License

MIT — see LICENSE.

Contributing

PRs welcome. Fork, branch, and open a pull request.


Use this repo as a GitHub template: click Use this template on GitHub to create your own project from this starter.

About

A ready-to-use Express.js starter for building Node.js APIs and web applications, configured for deployment on Cloudways.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages