Deploy Express

Any Node.js app with a package.json containing a start script deploys out of the box.

Detection

Leash detects Node.js apps by looking for a package.json with a start script in the scripts field.

Example App

index.js
const express = require('express')
const app = express()
const port = process.env.PORT || 8080
app.use(express.json())
app.get('/', (req, res) => {
res.json({ message: 'Hello from Leash!' })
})
app.get('/api/health', (req, res) => {
res.json({ status: 'ok', uptime: process.uptime() })
})
app.listen(port, () => {
console.log(`Server running on port ${port}`)
})

package.json

package.json
{
"name": "my-express-app",
"version": "1.0.0",
"scripts": {
"start": "node index.js"
},
"dependencies": {
"express": "^4.18.0"
}
}

Deploy

Terminal

$ cd my-express-app

$ leash deploy

✓ Detected Node.js

✓ Image built and pushed

✓ Deployed successfully!

→ https://my-express-app-arvin.un.leash.build

Important: use process.env.PORT

Leash injects the PORT environment variable at runtime. Make sure your app listens on process.env.PORT instead of hardcoding a port number.