project-2-starter
Initial App Setup
touch server.js
npm init -y
npm install express express-handlebars sequelize mysql2
Server Setup
- Require express
- Create an instance of express
app
- Create a port. Ensure you account for the environment variable in Heroku.
- Listen on the port.
- Add routes (
/api/config
is great for testing)
Confirm all this works. Then . . .
- Add body parsing middleware.
- Optional: Add in the express static route use for public folder
Handlebars Setup
- Require
express-handlebars
- Configure express-handlebars.
- Create the folder structure (/views/layouts/main.handlebars)
- Create an index.handlebars to inject into the
{{{body}}}
- Add get route to
res.render
index.
Sequelize Setup
- Run
sequelize init:config & sequelize init:models
(Confirm when you see config and models directories) - Create
schema.sql
file to store your new database creation queries. - Run the schema file in MySQL Workbench to create the database.
- Modify
config.json
file with database name and password (for development). - Create a basic model
- Update the server by requiring db, and syncing before server start.