This commit is contained in:
Kfir Dayan 2023-06-11 13:15:20 +03:00
parent 85aa426976
commit 37d5e2c844
2 changed files with 70 additions and 12 deletions

View file

@ -56,18 +56,76 @@ Request Body
} }
``` ```
Response Body Response Body
status code 200
``` ```
{ {
"user": { message:
"_id": "string", "User created successfully"
"name": "string", }
"email": "string", ```
"password": "string", status code 400
"createdAt": "string", ```
"updatedAt": "string", {
"__v": "number" message:
}, "User already exists"
"token": "string" }
```
status code 500
```
{
message:
"Internal server error"
}
```
Login - POST /users/login
Logs in a user.
Request Body
```
{
"email": "string",
"password": "string"
}
```
Response Body
status code 200
```
{
access-token:
"TOKEN"
} }
``` ```
# Products
Get All Products - GET /products
Gets all products.
Parameters
```
page: number(default: 0)
limit: number(default: 50)
```
Response Body
status code 200
```
{
products: [
{
_id: "string",
name: "string",
description: "string",
price: number,
image: "string",
createdAt: "string",
updatedAt: "string"
}
]
}
```
status code 404
```
{
message:
"Product not found."
}
````

View file

@ -53,6 +53,6 @@ export async function getProduct(req: Request, res: Response) {
res.json(product); res.json(product);
} catch (error) { } catch (error) {
console.error('Error getting product:', error); console.error('Error getting product:', error);
res.status(500).json({ error: 'An error occurred while getting the product.' }); res.status(404).json({ error: 'Product not found.' });
} }
} }