Step 1

Create a folder to store the files for this chapter. I called mine qnote-api. Add a .gitingore file to this directory:

.DS_Store
.vscode/*
.idea/*
node_modules/*

Open the terminal and change the directory to your project folder and run the following commands:

git init
git add .
git commit -m "Initial Commit"

Create a subfolder server and add an index.js file to it:

const express = require("express");
const app = express();
const port = process.env.PORT || 5000;

app.get("/", (req, res) => {
  res.send("QuickNote API!");
});

app.listen(port, () => {
  console.log(`Express app listening at port: http://localhost:${port}/`);
});

Run the command npm init -y in the terminal. Then, install Express: npm install express.

Finally, open the package.json file and update the "scripts" section:

  "scripts": {
+   "dev": "nodemon server",
+   "start": "node server",
    "test": "echo \"Error: no test specified\" && exit 1"
  },

You can run your Express app now (npm run dev in the terminal).

Save the changes and commit your code.