Server Page
First run npm install express inside the parent folder
Next create a file called server.js in the src folder
Now we create the server
The code for it looks like this:
require("./db/connection"); const express = require("express"); const app = express(); const router = require("[PATH TO ROUTE FILE HERE]") app.use(express.json()); app.use(router) const port = process.env.PORT || 5000; app.listen(port, () => { console.log(`Server listening on port ${port}...`); });
NOTE the first line starts the database connection This is very important and is easily missed To specify a specific port for example 3000 run this is in the terminal export PORT=3000