README
This commit is contained in:
parent
85aa426976
commit
37d5e2c844
2 changed files with 70 additions and 12 deletions
76
README.md
76
README.md
|
@ -56,18 +56,76 @@ Request Body
|
|||
}
|
||||
```
|
||||
Response Body
|
||||
status code 200
|
||||
```
|
||||
{
|
||||
message:
|
||||
"User created successfully"
|
||||
}
|
||||
```
|
||||
status code 400
|
||||
```
|
||||
{
|
||||
message:
|
||||
"User already exists"
|
||||
}
|
||||
```
|
||||
status code 500
|
||||
```
|
||||
{
|
||||
message:
|
||||
"Internal server error"
|
||||
}
|
||||
```
|
||||
Login - POST /users/login
|
||||
Logs in a user.
|
||||
|
||||
Request Body
|
||||
```
|
||||
{
|
||||
"user": {
|
||||
"_id": "string",
|
||||
"name": "string",
|
||||
"email": "string",
|
||||
"password": "string",
|
||||
"createdAt": "string",
|
||||
"updatedAt": "string",
|
||||
"__v": "number"
|
||||
},
|
||||
"token": "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."
|
||||
}
|
||||
````
|
||||
|
|
|
@ -53,6 +53,6 @@ export async function getProduct(req: Request, res: Response) {
|
|||
res.json(product);
|
||||
} catch (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.' });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue