An API for an ecommerce site
- Users can GET products.
- Users can register, login and delete their account.
- Users can add and remove products from their cart.
- Admin user do all CRUD operations on products.
- Clone the repo using
git clone https://github.com/mayan-sharma/Steve.git
- cd
steve
- Create
env
file in the root of the project.
MONGO_URI = ""
SECRET = ""
-
/api/user/login
- Allowed Methods:
POST
- Required fields:
{ email, password }
- Authenticates user info and returns a JWT token.
- Allowed Methods:
-
/api/user/register
- Allowed Methods:
POST
- Required fields:
{ name, email, password }
- Registers a user and returns a JWT token.
- Allowed Methods:
-
/api/user/
- Allowed Methods:
GET
- Authorization: Admin
- Returns a list of all users
- Allowed Methods:
-
/api/user/verify
- Allowed Methods:
GET
- Authorization: Bearer
- Check the validity of the JWT token.
- Allowed Methods:
-
/api/user/delete
- Allowed Methods:
DELETE
- Authorization: Bearer
- Deletes the user.
- Allowed Methods:
-
/api/products
- Allowed Methods:
GET
POST
GET
- Returns the list of all products.
POST
- Authorization: Bearer , Admin
- Add a product to the catalog
- Allowed Methods:
-
/api/products/:id
- Allowed Methods:
GET
POST
- Returns single product with id passed
- Allowed Methods:
-
/api/products/:id
- Allowed Methods:
PUT
DELETE
- Authorization: Bearer , Admin
PUT
- Required Fields:
{ name, price }
- Authorization: Bearer , Admin
- Updates a product
- Required Fields:
DELETE
- Deletes a product
- Allowed Methods:
-
/api/cart/:id
- Allowed Methods:
POST
DELETE
- Authorization: Bearer
POST
- Adds a product to the user's cart
DELETE
- Deletes a product from the user's cart
- Allowed Methods:
-
/api/cart/display
- Allwoed Methods:
GET
- Authorization: Bearer
- Return all products in the cart
- Allwoed Methods:
Pull requests are welcome.