This repo contains a basic Node and Express app that implements the backend functionality of an E-commerce applications. To get started, clone this repo and run yarn
in your terminal at the project root.
Your application must 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
Set up a .env file using the .envTemplate file provided. Note, SALT_ROUNDS should be a number between 1-10.
- Create a database called fantasy_worlds with postgres
- Run db-migrate up
- Run npm run start
- Database is running on - 5432
- Backend is running on - 3000
Follow the steps below.
Start By Creating a User - there's much you can do as a user.
POST localhost:3000/users/
{
"firstname": "myname",
"lastname": "mylastname",
"password": "mypassword"
}
Copy the generated Token and input it in Authorization, type - Bearen token.
Get localhost:3000/users/
Get localhost:3000/users/:id - replace :id with a number.
POST localhost:3000/users/auth
{
"firstname": "myname",
"password": "mypassword"
}
PUT localhost:3000/users/:id
{
"firstname": "yourname",
"lastname": "yourlastname",
"password": "mypassword"
}
DELETE localhost:3000/users/:id
Navigating the products route.
Get localhost:3000/products/
Get localhost:3000/products/:id - replace :id with a number.
User must be signed in - authorized users only.
POST localhost:3000/products/
{
"name": "MacBook Pro 14in",
"price": 1200000
}
PUT localhost:3000/products/:id
{
"name": "MacBook Pro 14in",
"price": 1250000
}
DELETE localhost:3000/products/:id
Navigating the orders route. Must be authenticated to perform any action.
- Get all orders: GET localhost:3000/orders/
- Get specific order: GET localhost:3000/orders/:id
- Complete an order: POST localhost:3000/orders/:id
- Create an order: POST localhost:3000/order/
- Delete an order: DELETE localhost:3000/orders/:id
- Get Completed order: GET localhost:3000/completed_orders