A simple e-commerce Go web application that handles authentication for users as well as creation, updating, listing, and deleting products.
- Git clone this repository
- Install pgAdmin4
cdinto the directory then rungo run main.go
A user can login with their credentials using
POST /users/login
{
"Email": "XXXXX",
"Password: "YYYYY",
}A user can sign up with their credentials using
POST /users/signup
{
"Name": "AAAAAA",
"Email": "XXXXX",
"Password: "YYYYY",
"Admin": false,
}Users passwords are hashed before being inserted into the database
All users are allowed to see the list of products stored in the database and to buy via Stripe
List
GET /productsBuy
POST/api/charges/{id}
{
"amount": 200,
"receiptEmail": "XXXXX"
}Admin users are allowed to add, remove, edit products existing in the database using the following endpoints
Create
POST /products
{
"Name": "pen",
"Quantity": 20,
"Price": 200
}Edit
PUT /products/{id}
{
"Name": "pen",
"Quantity": 20,
"Price": 200
}Delete
DELETE /products/{id}These endpoints are protected via JWT middleware.