Let’s start by building a small app using the well-known express.js library for JavaScript/nodejs.
Create a project folder and initialize a git repository:
$ mkdir ./my-app
$ cd my-app/
$ git init
Initialized empty Git repository in /Users/user/projects/my-app/.git/
Install express.js as a dependency using npm
:
$ npm install express --save
$ echo "node_modules" > .gitignore
Let’s create an app.js
file with the following content (inspired by the express.js hello world example):
const express = require('express')
const app = express()
const port = process.env.port ||Β 3000
app.get('/', (req, res) => {
res.send('Hello World!')
})
app.listen(port, () => {
console.log(`Example app listening on port ${port}`)
})
3000
for local development.Define a start
command in package.json
:
$ npm pkg set scripts.start="node app.js"
You can test the app locally by running: npm run start
and it will be available at http://localhost:3000/
.
Create an application on Runway:
$ runway app create
INFO checking login status
INFO created app "relaxed-meteor"
create app relaxed-meteor: done
next steps:
* commit your changes
* runway app deploy
* runway open
Set the port:
$ runway app config set PORT=3000
And deploy:
$ runway app deploy && runway open
Congratulations, you deployed an express.js application to Runway! π