Express apps generally follow a pattern - our server.js
file is already checking off a number of the boxes.
// Import dependancies
// - brings in all of the modules we'll be using
require('dotenv').config()
const express = require('express')
// Create an instance of an express app
// - create the actual server object
const server = express()
// Connect the app to global middleware
// - functions that every endpoint passes through
server.use(express.json())
// Endpoints check connection and perform functions
// - the code that sends and receives messages and determines what to do
server.get('/hello', (req, res) => {
res.json({ message: 'Hello from the Server' })
})
// Listen to or export server
// - what the rest of the world connects to
module.exports = server
express.json()
parses JSON data out of incoming requests