touch server.js
npm init -y
npm install express mongoose
- Optional:
npm install nodemon -D
- Require express and mongoose
- Create an instance of express.
- Define a PORT to listen on.
- Listen on the PORT.
- Add middleware
- Add routes (Optional: /api/config to test)
- Write mongoose.connect with process environment variable or local connection string and config object.
- Setup logging for successful or error connection.
- Require mongoose
- Bring in the schema
- Create a new schema
- Create the model from the schema
- Export the model
- Create the controller
- Require express
- Declare the router off Express
- Export the router (Routes go in the middle)
- Require the controller in server.js
- Use the controller in server.js
- Require the models for that route.
- Query the DB using mongoose methods
- Chain the promise, res.json the result
- Be sure to catch any errors.