A system design recreation of a existing API located at https://github.com/bootdme/ProjectAtelier
- Run
git cloneto clone the repository. - Run
npm installto install dependencies. - Download CSV Data and extract
csv/folder to root directory. - Import data to local database with
psql -U postgres -f db/schema.sql - Run
npm run startto start the Node server. - OPTIONAL: Run
npm run testto execute test suites.
NOTE: Default env credentials are set in db/index.js as
const poolConfig = {
user: process.env.PGUSER || 'postgres',
password: process.env.PGPASSWORD || '',
host: process.env.PGHOST || 'localhost',
port: process.env.PGPORT || 5432,
database: process.env.PGDATABASE || 'qa',
};To set up local PostgreSQL database with users preferred credentials, create a copy of .example.env, name it .env, and input credentials
GET routes:
/qa/questionsretrieves a list of questions for a particular product.
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| product_id | integer | Specifies the product for which to retrieve questions. |
Parameters
| Parameter | Type | Description |
|---|---|---|
| page | integer | Selects the page of results to return. Default 1. |
| count | integer | Specifies how many results per page to return. Default 5. |
/qa/questions/:question_id/answersreturns answers for a given question.
Parameters
| Parameter | Type | Description |
|---|---|---|
| question_id | integer | Required ID of the question for wich answers are needed. |
Query Parameters
| Parameter | Type | Description |
|---|---|---|
| page | integer | Selects the page of results to return. Default 1. |
| count | integer | Specifies how many results per page to return. Default 5. |
POST routes:
/qa/questionsadds a question for the given product.
Body Parameters
| Parameter | Type | Description |
|---|---|---|
| body | text | Text of question being asked |
| name | text | Username for question asker |
| text | Email address for question asker | |
| product_id | integer | Required ID of the Product for which the question is posted |
/qa/questions/:question_id/answersadds an answer for the given question.
Parameters
| Parameter | Type | Description |
|---|---|---|
| question_id | integer | Required ID of the question to post the answer for |
Body Parameters
| Parameter | Type | Description |
|---|---|---|
| body | text | Text of question being asked |
| name | text | Username for question asker |
| text | Email address for question asker | |
| photos | [text] | An array of urls corresponding to images to display |
PUT routes:
/qa/questions/:question_id/helpfulupdates a question to show it was found helpful./qa/questions/:question_id/reportupdates a question to show it was reported.
Parameters
| Parameter | Type | Description |
|---|---|---|
| question_id | integer | Required ID of the question to update |
/qa/answers/:answer_id/helpfulupdates an answer to show it was found helpful./qa/answers/:answer_id/reportupdates an answer to show it has been reported.
Parameters
| Parameter | Type | Description |
|---|---|---|
| answer_id | integer | Required ID of the answer to update |