Setup Express

Install Express

npm install express

Create the express app file

touch src/app.js

Code app.js

import express from 'express';
const app = express();

export default app;

Enter port info to .env

echo '' >> ./.env
echo 'PORT=3000' >> ./.env

Setup entry point

Create entry point file

touch src/server.js

Code server.js entry point

import 'dotenv/config';
import app from './app.js';
const port = process.env.PORT || 3000;

app.listen(port, () => {
  console.log(`Server running on http://localhost:${port});
});

Set package entry point as server.js

npm pkg set main=src/server.js

Add dev script

npm pkg set scripts.dev="node src/server.js"

Test

npm run dev

Commit

git add .
git commit -m 'Adds express setup'

Next:
Setup middleware