Creates a new user
body:
{
"username": "string",
"password": "string",
"role": "string"
}
response:
{
"message": "string",
"user": {
"id": "string",
"username": "string",
"role": "string",
"deposit": "number"
}
}
authenticates user
body:
{
"username": "string",
"password": "string"
}
response:
{
"id": "string",
"username": "string",
"role": "string",
"deposit": "number"
}
// jwt token sent in cookie
gets current user
response:
{
"id": "string",
"username": "string",
"role": "string",
"deposit": "number"
}
logs out user
response:
{
"message": "string"
}
updates user
body:
{
// optional fields
"username": "string",
"password": "string",
"role": "string"
}
response:
{
"message": "string",
"user": {
"id": "string",
"username": "string",
"role": "string",
"deposit": "number"
}
}
deletes user
response:
{
"message": "string"
}
deposits money
body:
{
"amount": "number" // should be a value in [5, 10, 20, 50, 100]
}
response:
{
"message": "string",
"deposit": "number"
}
resets user deposit
response:
{
"message": "string",
"deposit": "number"
}
gets all products
response:
[
{
"id": "string",
"productName": "string",
"cost": "number",
"amountAvailable": "number",
"sellerId": "number"
}
]
creates new product
body:
{
"productName": "string",
"cost": "number", // cost should be a multiple of 5
"amountAvailable": "number",
}
response:
{
"message": "string",
"product": {
"id": "string",
"productName": "string",
"cost": "number",
"amountAvailable": "number",
"sellerId": "number"
}
}
gets product
response:
{
"id": "string",
"productName": "string",
"cost": "number",
"amountAvailable": "number",
"sellerId": "number"
}
updates product
body:
{
// optional fields
"productName": "string",
"cost": "number",
"amountAvailable": "number",
}
response:
{
"message": "string",
"product": {
"id": "string",
"productName": "string",
"cost": "number",
"amountAvailable": "number",
"sellerId": "number"
}
}
deletes product
response:
{
"message": "string"
}
buys product
body:
{
"amount": "number"
}
response:
{
"message": "string",
"product": {
"id": "string",
"productName": "string",
"cost": "number",
"amountAvailable": "number",
"sellerId": "number"
},
// return user change in coins
"change": [
"5": "number"
"10": "number"
"20": "number"
"50": "number"
"100": "number"
]
}