Storefront backend restful api that facilitates creationg of orders, products and users. User can order for a product and completed the purchase through various endpoints.
- Clone this repo and run
yarnin your terminal at the project root. - Ensure you either have
dockerinstalled in your machine or a local instance ofpostgresinstalled in your machine. - For
DOCKERthere is adocker-compose.ymlfile at the root of the project. Navigate to the project's directory and rundocker compose up -dto run your docker instance. - Use
docker compose psto check if the instance is running before connecting to it. You can proceed to login to it usingpsql -U postgres - For
postgres local instance, first check if the service is running either from the services window [windows os] orsystemctl status postgresqlfor linux system. Then login to the db usingpsql -U postgres - Rename the
.env.examplefile to.envto use it as the configuration enviroment file. - To run migrations and create db. First run
yarn create-dev-dbto create the db andyarn migrate-dev-dbto create migrations. - Change the
ENVvariable totestin the.envfile and runyarn testto run tests. - Change the
ENVvariable todevin the.envfile and runyarn start:devfor development purposes andyarn start:prodfor production.
- 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
- bcypt to hash password
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | /api/users | Retrieve list of users | 200 OK |
| POST | /api/users | Register a user | 201 OK |
| GET | /api/users/1 | Retrieve a single user | 200 OK |
| UPDATE | /api/users/1 | Update a user | 201 OK |
| DELETE | /api/users/1 | Delete a user | 200 OK |
| GET | /api/users/invalid | Validate invalid user | 400 BAD REQUEST |
| GET | /api/users/100 | Validate if user exists | 404 NOT FOUND |
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | /api/orders | Retrieve list of orders | 200 OK |
| POST | /api/orders | Register an order | 201 OK |
| GET | /api/orders/1 | Retrieve a single order | 200 OK |
| UPDATE | /api/orders/1 | Update an order | 201 OK |
| DELETE | /api/orders/1 | Delete an order | 200 OK |
| GET | /api/orders/invalid | Validate invalid order id | 400 BAD REQUEST |
| GET | /api/orders/100 | Validate if order exists | 404 NOT FOUND |
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | /api/products | Retrieve list of products | 200 OK |
| POST | /api/products | Register a product | 201 OK |
| GET | /api/products/1 | Retrieve a single product | 200 OK |
| UPDATE | /api/products/1 | Update a product | 201 OK |
| DELETE | /api/products/1 | Delete a product | 200 OK |
| GET | /api/products/invalid | Validate invalid product id | 400 BAD REQUEST |
| GET | /api/products/100 | Validate if product exists | 404 NOT FOUND |
| Method | Endpoint | Description | Response |
|---|---|---|---|
| GET | /api/dashboard/user-order | Retrieve a user with specific order | 200 OK |
| GET | /api/dashboard/users-orders | Retrieve list of all orders placed | 200 OK |
| GET | /api/cart/1 | Retrieve a specific order in cart | 200 OK |
| UPDATE | /api/users/1/checkout/1 | Checkout an order | 201 OK |