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
yarn
in your terminal at the project root. - Ensure you either have
docker
installed in your machine or a local instance ofpostgres
installed in your machine. - For
DOCKER
there is adocker-compose.yml
file at the root of the project. Navigate to the project's directory and rundocker compose up -d
to run your docker instance. - Use
docker compose ps
to 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 postgresql
for linux system. Then login to the db usingpsql -U postgres
- Rename the
.env.example
file to.env
to use it as the configuration enviroment file. - To run migrations and create db. First run
yarn create-dev-db
to create the db andyarn migrate-dev-db
to create migrations. - Change the
ENV
variable totest
in the.env
file and runyarn test
to run tests. - Change the
ENV
variable todev
in the.env
file and runyarn start:dev
for development purposes andyarn start:prod
for 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 |