-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from deolla/feat/get-product
feat: Implement GET All User Products Endoint with Pagination (Page, Limit, Offset)
- Loading branch information
Showing
16 changed files
with
1,154 additions
and
819 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,93 @@ | ||
import express from 'express'; | ||
import { ProductController } from '../controllers'; | ||
import ProductController from '../controllers/ProductController'; | ||
import { authMiddleware } from '../middleware'; | ||
|
||
const productRouter = express.Router(); | ||
const productController = new ProductController(); | ||
|
||
/** | ||
* @swagger | ||
* tags: | ||
* name: Products | ||
* description: API for products management. | ||
*/ | ||
|
||
/** | ||
* @swagger | ||
* /api/v1/products/: | ||
* get: | ||
* summary: Get paginated products | ||
* tags: [Products] | ||
* parameters: | ||
* - in: query | ||
* name: page | ||
* schema: | ||
* type: integer | ||
* default: 1 | ||
* description: Page number | ||
* - in: query | ||
* name: limit | ||
* schema: | ||
* type: integer | ||
* default: 10 | ||
* description: Number of items per page | ||
* responses: | ||
* 200: | ||
* description: Success | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* status: | ||
* type: string | ||
* status_code: | ||
* type: integer | ||
* data: | ||
* type: object | ||
* properties: | ||
* page: | ||
* type: integer | ||
* limit: | ||
* type: integer | ||
* totalProducts: | ||
* type: integer | ||
* products: | ||
* type: array | ||
* items: | ||
* $ref: '#/models/product' | ||
* 400: | ||
* description: Invalid query parameters | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* error: | ||
* type: string | ||
* message: | ||
* type: string | ||
* status_code: | ||
* type: integer | ||
* 500: | ||
* description: Internal server error | ||
* content: | ||
* application/json: | ||
* schema: | ||
* type: object | ||
* properties: | ||
* error: | ||
* type: string | ||
* message: | ||
* type: string | ||
* status_code: | ||
* type: integer | ||
*/ | ||
|
||
productRouter.get( | ||
'/products', | ||
'/', | ||
authMiddleware, | ||
productController.listProducts.bind(productController) | ||
productController.getProductPagination.bind(productController) | ||
); | ||
|
||
export { productRouter }; |
Oops, something went wrong.