https://exercise-app-backend-420.herokuapp.com
- Create a new branch off of
main
(unless it's a simple change - then committing/pushing straight tomain
should be fine, just keep the commits tidy). - Write code.
- Create a PR and post it in Discord. We aren't enforcing approvals, but just get it sanity checked if it's a big / risky change.
- Squash and merge.
- Merges to
main
will automatically deploy to Heroku.
- Follow this guide. Postgres will not run locally on WSL 1.
- Install an SQL client of your choice - I use DBeaver for Windows.
- Start the Postgres server (probably via your CLI). For WSL the command is
sudo service postgresql start
. If you use another OS, add your instructions here. - Connect to your Postgres server via your SQL client.
- Note: If you run into the error
FATAL: password authentication failed for user "postgres"
follow these steps.
- Note: If you run into the error
- Simon downloaded the PostgreSQL installer (v. 14.4-1 at time of writing).
- Used default settings in the installer but set my own password. This will install pgAdmin4 by default.
- After installed, open pgAdmin4 and enter your password and create our DB with next step.
- Using the pgAdmin4 browser on the left, click (Servers -> PostgreSQL 14 -> Databases -> 'postgres'). The query tool in the toolbar should now be black, (DB icon with a play button).
- Create the DB by copy pasting in the
database/migrations/000001-create-database.sql
command into the Query and press Play icon. - Right click 'Databases' in the browser and 'refresh'. You should now see
exercise-app
in the list.
- Ensure your
.env
contains all the following:PORT=5000
.GOOGLE_CLIENT_ID="get-from-discord-server"
.GOOGLE_CLIENT_SECRET="get-from-discord-server"
.SESSION_SECRET="get-from-discord-server"
.FRONTEND_ORIGIN="http://localhost:3000"
.THIS_ORIGIN="http://localhost:5000"
.POSTGRES_PASSWORD="insert-your-password-here"
.
- Start the BE server
npm start
and it should connect. - Run the queries inside
/database/migrations
in ascending order.- Note: You'll likely have to create the database (very first migration file) and then reconnect to that database before running the other queries.
- in pgAdmin4, you can select the new DB from the dropdown list after selecting the Query Tool.
- OPTIONAL: Insert a test user using the
/database/helpers/insert-user.sql
query. When the app is running (instructions below), you can verify the DB connection by accessinglocalhost:5000/users
and your test user should come back as a JSON object.
git clone git@github.com:reezy24/exercise-app-backend.git
cd exercise-app-backend
npm i
npm run dev
- Check the app is running at
localhost:5000/ping
.
You only need to do this if you want to:
- connect to the live DB instance
- deploy a branch other than
main
Any merges to main
branch will automatically deploy to Heroku, i.e. you don't need to follow these steps in order to deploy your changes.
- Install the Heroku CLI.
cd
into the root of the project if you aren't already.heroku git:remote -a exercise-app-backend-420
heroku pg:credentials:url DATABASE --app exercise-app-backend-420
- It should output connection details under
Connection info string
. You can use these to connect via your SQL client.
NOTE: You should probably notify the Discord if you're going to do this.
- Commit your changes to
your-branch
. git push heroku your-branch:main
Sends back "pong".
Sends back the request.
Lists users.