Changes include the inclusion of the request parameter (`_req`) in the `getAllBrand` and `getAllCategory` functions and some code format adjustment in `category.controller.ts`. This addition allows more flexibility in handling the request if needed in the future. The `total` field has also been added to the category output to conveniently provide category count.
Signed-off-by: Mathis <yidhra@tuta.io>
The `getBySlugCategory` function in `category.controller.ts` now has a detailed comment. The comment includes a description of the function, its parameters, and its return value.
Signed-off-by: Mathis <yidhra@tuta.io>
The `category.controller.ts` has been updated to handle deleting a category and retrieving a category by slug. The `deleteCategory` function takes a category slug from the request params and first checks if the category exists before attempting to delete it. While the `getBySlugCategory` function simply retrieves a category by its slug.
Issue: #12
Signed-off-by: Mathis <yidhra@tuta.io>
The getAllCategory function is added in `category.controller.ts`. This function retrieves all categories and presents an error message if it fails. Specifically, it interacts with the Category service to get all categories, logs the process, and maps each element to an {`id`, `display_name`, `slug_name`} object before sending the response.
Issue: #12
Signed-off-by: Mathis <yidhra@tuta.io>
Remove unused import `{IDbCategory}` from `category.controller.ts`. This reduces clutter and increases code clarity in the file.
Issue: #12
Signed-off-by: Mathis <yidhra@tuta.io>
This commit includes the creation of an updateCategory function in the category controller which allows for existing categories to be updated. It also includes appropriate error handling and response messages. In addition, it also introduces logging for the successful creation of a category.
Issue: #12
Signed-off-by: Mathis <yidhra@tuta.io>
A new controller, category.controller.ts, has been added to handle category creation.
This includes validation to prevent the creation of duplicate categories and error handling in the event of failure to create a new category.
Issue: #12
Signed-off-by: Mathis <yidhra@tuta.io>