diff --git a/README.md b/README.md index adb9405..6c1405e 100644 --- a/README.md +++ b/README.md @@ -56,18 +56,76 @@ Request Body } ``` Response Body +status code 200 ``` { - "user": { - "_id": "string", - "name": "string", - "email": "string", - "password": "string", - "createdAt": "string", - "updatedAt": "string", - "__v": "number" - }, - "token": "string" -} + 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 +``` +{ + "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." +} +```` diff --git a/src/controllers/ProductController.ts b/src/controllers/ProductController.ts index 8c0dfbd..37a17f1 100644 --- a/src/controllers/ProductController.ts +++ b/src/controllers/ProductController.ts @@ -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.' }); } }