This is the API for the booklist app, this is built to be the backend for any front end application like React, Vue, etc...
-
Fork the project (repository) first so that you have a copy of the project in your account.
-
Find the project you just forked in the list of project under your account, and then clone the project down and run npm install to install node modules.
-
Add a remote repository with this command [git remote add fcc https://github.com/FreeCodeCamp-SLC/booklist-express-api]
- This is to ensure you are still able to pull down the latest changes from the original project. If you're new to using Git/GitHub and pushing/pulling, just ask one of the project leaders or ask during a meetup to go over this.
-
Setup PostgreSQL on your pc.
- Download PostgreSQL from here, version number shouldn't matter.
- Install PostgreSQL with all the default settings, remember the password you chose while installing.
- After PostgreSQL is done installing, run pgAdmin, it will ask for the password you set while installing.
- Once pgAdmin is running in your browser, expand servers and then PostgreSQL on the left side, right click database and select create > database, you will need a database called 'booklist', go ahead and create another database called 'booklist_test' in case you ever get into writing backend tests.
-
Create a .env file in the root of this project, we will be putting your local database password env variable here. There is also 3 other key/value pairs you'll need here, message Alex Puhl on the UtahJS Slack to get this.
- DB_PASSWORD=yourPassword
- AUTH0_JWKSURI=MESSAGE_ALEX_FOR_VALUE
- AUTH0_AUDIENCE=MESSAGE_ALEX_FOR_VALUE
- AUTH0_ISSUER=MESSAGE_ALEX_FOR_VALUE
-
We will be using Knex to setup the tables and seed some data, we will need to install knex globally if you don't have it already.
- You can check what packages are globally installed on your PC with [npm list -g --depth 0]
- Install knex globally with [npm i -g knex]
- cd into the /db folder
- Run the command [knex migrate:latest] to create the database tables for booklist
- Run the command [knex seed:run] to seed the tables with seed data.
Runs the app in whatever mode NODE_ENV is set to, by default that should be 'development'.
Postman is a useful tool for API development, we can use it to test sending REST requests to the server without a front end client.
- Download postman and install it.
- You can create a postman account if you want. This will allow you to then install postman on another pc and when you login all your saved network requests will download to that pc.
- We have a file in the root of this project called Booklists.postman_collection.json, we will want to import this into postman by clicking on File > Import from within Postman. Find the file Booklists.postman_collection.json from inside this project.
- You should now have all the api requests inside a folder called Booklists with the subfolders List Route, Book Route, Reading Status Route.