Storefont is a backend application that allows an ecommerce store to send request via RESTFUL API. The full requirements about the routes are available in the REQUIREMENTS.md file
The application make use of the following libraries:
- Postgres for the database
- Node/Express for the application logic
- dotenv from npm for managing environment variables
- db-migrate from npm for migrations
- jsonwebtoken from npm for working with JWTs
- jasmine from npm for testing
npm install npm run build npm run start
You are required to create a duplicate of .env.sample file, rename the new file as .env and then update the variables to the values below The environment variable sample are stored in the .env.sample.
- The database.json file would parse the environment variable to the right database
In psql prompt, run the following: CREATE USER store_front_user WITH PASSWORD 'password'; CREATE DATABASE store_front; CREATE DATABASE store_front_test; \c store_front GRANT ALL PRIVILEGES ON DATABASE store_front TO store_front_user; \c store_front_test GRANT ALL PRIVILEGES ON DATABASE store_front_test TO store_front_user;
POSTGRES_HOST=127.0.0.1 POSTGRES_DB=store_front POSTGRES_USER=store_front_user POSTGRES_PASSWORD=password POSTGRES_TEST_DB=store_front_test POSTGRES_TEST_USER=store_front_user POSTGRES_TEST_PASSWORD=password
BYCRYPT_PASSWORD=password SALT_ROUNDS=10 ENV=dev TOKEN_SECRET=mytokenSecret
In this repo there is a REQUIREMENTS.md
document which outlines what this API needs to supply for the frontend, as well as the agreed upon data shapes to be passed between front and backend. This is much like a document you might come across in real life when building or extending an API.
Your first task is to read the requirements and update the document with the following:
-
Determine the RESTful route for each endpoint listed. Add the RESTful route and HTTP verb to the document so that the frontend developer can begin to build their fetch requests.
Example: A SHOW route: 'blogs/:id' [GET] -
Design the Postgres database tables based off the data shape requirements. Add to the requirements document the database tables and columns being sure to mark foreign keys.
Example: You can format this however you like but these types of information should be provided Table: Books (id:varchar, title:varchar, author:varchar, published_year:varchar, publisher_id:string[foreign key to publishers table], pages:number)
NOTE It is important to remember that there might not be a one to one ratio between data shapes and database tables. Data shapes only outline the structure of objects being passed between frontend and API, the database may need multiple tables to store a single shape.
Now that you have the structure of the databse outlined, it is time to create the database and migrations. Add the npm packages dotenv and db-migrate that we used in the course and setup your Postgres database. If you get stuck, you can always revisit the database lesson for a reminder.
You must also ensure that any sensitive information is hashed with bcrypt. If any passwords are found in plain text in your application it will not pass.
Create the models for each database table. The methods in each model should map to the endpoints in REQUIREMENTS.md
. Remember that these models should all have test suites and mocks.
Set up the Express handlers to route incoming requests to the correct model method. Make sure that the endpoints you create match up with the enpoints listed in REQUIREMENTS.md
. Endpoints must have tests and be CORS enabled.
Add JWT functionality as shown in the course. Make sure that JWTs are required for the routes listed in REQUIUREMENTS.md
.
Before submitting, make sure that your project is complete with a README.md
. Your README.md
must include instructions for setting up and running your project including how you setup, run, and connect to your database.
Before submitting your project, spin it up and test each endpoint. If each one responds with data that matches the data shapes from the REQUIREMENTS.md
, it is ready for submission!