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>
In `credential.service.ts`, markers were added to functions `getHashFromPassword` and `comparePassword` to indicate necessity for testing. This provides clear indications for developers about which functions require tests to be written or updated.
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 addition of a new function, `updateCategory` in the category.service.ts file. This function allows for updating a category in the database. Error handling and logging are also implemented within the function.
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>
- Revised comments replacing 'TODO' with 'FIX' and 'FEAT' in AuthController.
- Renamed 'AuthController.ts' to 'auth.controller.ts' and updated the reference in the router.
- Planned for implementing re-auth by current password in case of password change.
Signed-off-by: Mathis <yidhra@tuta.io>
A TODO comment has been added in the mysql.service.ts file as a reminder to get models in category in the future. This is to ensure that future development accounts for this necessity.
Signed-off-by: Mathis <yidhra@tuta.io>
A comment has been added in the category service to return the new id in the future. Currently, the implementation returns a boolean value after creating a new category, but there is a plan to update this to return the generated id.
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>
The return type of the createCategory function in category.service.ts has been changed from unknown to boolean. Now, the function will return true if the creation is successful, and false if an error occurs.
Signed-off-by: Mathis <yidhra@tuta.io>
Several method calls in category.service.ts were incorrectly using IDbCategory instead of Category in MysqlService. This commit fixes the naming to correctly use Category in all method calls to ensure correct function execution.
Issue: #11
Signed-off-by: Mathis <yidhra@tuta.io>
Refactor the category service by:
- Calling methods from MysqlService.IDbCategory instead of MysqlService.Category.
- Adding new methods: getById and deleteCategory with typed return and clear comments.
These changes enhances code flexibility and readability.
Issue: #11
Signed-off-by: Mathis <yidhra@tuta.io>
Update category service functions with added getBySlug function and refactor getAllCategory to getAll. Exception handling has been improved, returning null on error.
Issue: #11
Signed-off-by: Mathis <yidhra@tuta.io>
The commit updates the 'category.service.ts' file by refactoring the UUID usage. Previously, the UUID feature was imported as a whole, but now only the v4 function is imported for efficiency. It introduces a new function 'getAllCategory' to fetch all categories. This, combined with better error handling and logging, leads to improved service reliability.
Issue: #11
Signed-off-by: Mathis <yidhra@tuta.io>
A new CategoryService has been added in the services layer. This includes a function createCategory for creating a new category using IDbCategory data. Some placeholders for future features such as get, delete and retrieve by id or slug are also included.
Issue: #11
Signed-off-by: Mathis <yidhra@tuta.io>
The changes introduce two new methods in mysql.service.ts. The getById method retrieves a category from the database using its ID while the delete method will delete a category from the database using the provided category ID. Both methods return promises.
Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
This commit adds a getById function to the mysql.service.ts file. The added functionality allows retrieving category data from the mysql database by id. Error handling has been included for undefined or invalid id cases.
Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
Added a new method getBySlug to retrieve a category by its slug in mysql.service.ts. Also, updated the getAll method by specifying the return type to Promise<Array<IDbCategory>> for better type checking.
Issue: #6
Signed-off-by: Mathis <yidhra@tuta.io>
This commit augments the VCS XML with "CommitMessageInspectionProfile". It enables two inspection tools: "CommitFormat" and "CommitNamingConvention", meant to enforce commit standards and conventions within the project. These tools will raise a warning when they detect a violation.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit adds a new `getAll` function in the `mysql.service.ts` file, which retrieves all categories from the database. It executes a SQL query and includes error handling that either resolves with an array of category objects or rejects with an Error object.
BREAKING-CHANGE: #6
Signed-off-by: Mathis <yidhra@tuta.io>
The return types for the 'insert' and 'update' methods in mysql.service.ts have been updated to 'Promise<unknown>'. Also, detailed JSDoc comments have been added for 'insert' and 'update' methods for both User and Category entities. No functionality changes have been made.
Signed-off-by: Mathis <yidhra@tuta.io>
This update introduces changes in the 'mysql.service.ts' to allow create and update operations for categories. The 'INSERT INTO' SQL query has been adjusted from targeting `users` to `categories`. An `update` function has also been added to allow updates in category data. The import order has been rearranged for better readability.
Signed-off-by: Mathis <yidhra@tuta.io>