Project 3 Backend Starter Code
Project 3 Starter Code Links
Express Backend Set-up
To Install
- Fork and clone
https://git.generalassemb.ly/Interapt/project3-backend-starter
cd
into the app andnpm install
- From the command line run
createdb project3-backend-dev
- Run
npm start
.
Starter End Points
You have two starter endpoints:
-
GET
api/users
-
POST
api/users
-
Your
config/config/json
is set-up to access the Heroku Postgres production database instance.
{
"development": {
"database": "project3-backend-dev",
"host": "127.0.0.1",
"dialect": "postgres"
},
"production": {
"use_env_variable": "DATABASE_URL",
"dialect": "postgres"
}
}
- This app also has
cors
andnodemon
installed. - Sequelize Cheatsheet
Test the endpoints with Postman
React Frontend Set-up
To Install
- Fork and clone
https://git.generalassemb.ly/Interapt/project3-frontend-starter
cd
into the app andnpm install
- Run
npm start
. You should see this in the browser:
Axios
The app has axios installed. You have one method called getUsers
that hits your Express backend api/users
. Check the browser console for the response.
Heroku
Create Free Heroku Account
Install the Heroku CLI
Heroku Node/Express Deployment Docs
- Also syncing the Sequelize models so that the tables will automatically be created:
var db = require('./models');
db.sequelize.sync();
## Connect Heroku DB to PG Admin
Heroku Stuff
- Right click on
Servers
and select Create > Server...
- On your Heroku App dashboard, click on Heroku Postgres
- On the next screen choose Settings, then View Database Credentials
Database URL
For security, we'll add the Heroku Postgres URL add heroku env variable to heroku dashboard
PG Admin Stuff
- In the
Name
field, enter the name of your database.
-
In the
Connection
Tab:Hostname/Address
is your Heroku PostgresHost
Maintenance Database
is your Heroku PostgresDatabase
Username
is your Heroku PostgresUser
Connect to your production server Terminal
Run this command from your back end app folder: heroku run bash
From here you can run commands like sequelize db:migrate
or sequelize db:seed:all
https://project3-backend-test.herokuapp.com/users