81 Commits

Author SHA1 Message Date
0ed130f7b8
feat(services): update MySQL service to fetch brand data
- Corrected the SQL query in fetching brand data based on ID.
- Added a new function, `getBySlug`, to fetch brand data using the brand slug. This ensures a flexible data access method thus enhancing the service's usability.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:38:41 +02:00
50c1ff797f
feat(services): add getById function to mysql.service
The code now includes a `getById` function in `mysql.service.ts`, which fetches a category by its id. This function will reject with an error message if brandId is not defined or if its length is not 36. The query is executed using a MysqlHandler instance.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:36:12 +02:00
2640ebbc70
feat(controllers): add detailed comment to getBySlugCategory function
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>
2024-04-25 16:31:33 +02:00
a992868eb6
feat(services): add 'getAll' function to mysql.service.ts
A new function named `getAll` has been added to `mysql.service.ts`. This function is designed to retrieve all records from the `brands` table. It returns a promise that resolves to an array of `IDbBrand` objects representing the retrieved records.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:29:39 +02:00
f3fc63502d
feat: Replace express-xss-sanitizer with helmet
The security middleware `express-xss-sanitizer` has been replaced with `helmet` for enhanced security measures. `helmet` provides better protection against potential security vulnerabilities.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:26:52 +02:00
44b04459fb
feat(services): add detailed comments and specify return types in mysql.service
In the `mysql.service`, this commit adds detailed doc-block comments for `insert` and `update` functions under `Brand` and `Category`. Additionally, the return types of the `update` functions under `Brand` and `Category` are now specifically defined as `Promise<number>`, providing clarity on the expected returns.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:26:29 +02:00
64aa814d2c
feat(services): add update method to mysql service
An `update` method is added to the `mysql.service.ts` for handling database updates. This new function checks for validity of the `id` before constructing and executing an SQL update statement. Errors are also caught and handled.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:24:02 +02:00
016f7fa9d4
feat(services): add brand insert method in mysql service
- Adjusted import syntax for IDbCategory interface
- Imported IDbBrand from database interfaces
- Added a new `insert` method in Brand object in MysqlHandler to insert brand data into the database. The method resolves with execution of SQL command and rejects on error or invalid ID.

Issue: #5
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:19:27 +02:00
01241dff4b
fix(services): correct database table name in mysql.service.ts
Update the hardcoded table name in the raw SQL query within mysql.service.ts. We changed `categorys` to `categories` to align with the actual database schema.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:07:29 +02:00
dda3eea9e1
feat(interfaces): add IReqRegister interface
This interface defines the register request structure, including `username`, `displayName`, `firstName`, `lastName`, `password`, and `gdpr` status. This will ensure consistency in the form of request data throughout the application.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:06:33 +02:00
a430044d95
feat(interfaces): add IReqLogin interface
The new IReqLogin interface defines the request shape for user login. It includes two string properties - username and password.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 16:06:02 +02:00
6c601e0b42
feat(app): add helmet for XSS protection
In order to improve security, we've added Helmet to the app to provide protection against cross-site scripting (XSS) attacks. This integration involves enabling the xss filter middleware through Helmet.

Issue: #3
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 15:56:48 +02:00
3ee76fb965
feat(routes): add CategoryController to category routes
Category routes have been updated to utilize the `CategoryController`. New, getAll, getBySlug, update, and delete methods from CategoryController are integrated with their corresponding category routes.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 15:19:50 +02:00
8b306e9a31
build(package): add uuid to dependencies
The package.json has been updated to include the 'uuid' package in both main and dev dependencies. This includes the addition of 'uuid' version "^9.0.1" to the list of dependencies and '@types/uuid' version "^9.0.8" to the list of devDependencies.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-25 15:03:08 +02:00
62cb05cb33
feat(controllers): add delete and getBySlug methods in category controller
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>
2024-04-25 15:02:46 +02:00
da001bf7cc
docs(services): add test markers to credential functions
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>
2024-04-25 14:54:17 +02:00
cd51a04aba
feat(controllers): add getAllCategory function in category controller
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>
2024-04-25 14:52:42 +02:00
bd80518b5f
refactor(controllers): remove unused import in category.controller
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>
2024-04-25 14:44:24 +02:00
ab3b3c9cf5
feat(services): add updateCategory functionality in category.service
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>
2024-04-25 14:43:41 +02:00
56a1722412
feat(controllers): add update category functionality in category controller
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>
2024-04-25 14:42:42 +02:00
36ad90eda6
feat(controllers): Refactor AuthController and update router reference
- 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>
2024-04-25 14:23:13 +02:00
73e086be44
docs(services): add TODO comment in mysql.service
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>
2024-04-25 14:22:25 +02:00
a582f8c431
docs(services): add comment for future improvement in category service
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>
2024-04-25 14:22:02 +02:00
23116f4345
feat(controllers): add category creation functionality
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>
2024-04-25 14:21:24 +02:00
4a9bc402b4
feat(services): change return type in createCategory function
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>
2024-04-25 14:11:15 +02:00
f3cd6c5985
fix(services): correct MysqlService method calls in category.service.ts
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>
2024-04-25 14:00:07 +02:00
325c6ec6a0
feat(services): update methods in category service
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>
2024-04-25 13:55:55 +02:00
11be3a40c3
feat(services): update category service functions
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>
2024-04-25 13:50:45 +02:00
3d3bc8580a
feat(services): update category.service with improved UUID usage and new function
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>
2024-04-25 13:46:08 +02:00
38b6b05190
feat(services): add CategoryService with createCategory function
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>
2024-04-25 13:33:09 +02:00
0abdbab627
feat(services): add getById and delete methods in mysql.service.ts
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>
2024-04-25 12:52:42 +02:00
3328c5a1df
feat(services): add getById function to mysql.service
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>
2024-04-25 12:30:32 +02:00
ead64291df
feat(services): add getBySlug method to MysqlService and refine getAll method
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>
2024-04-25 12:27:25 +02:00
25b573d3a4
feat(others): enhance VCS XML with commit message inspection tools
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>
2024-04-25 12:20:31 +02:00
02383b8c8a
feat(services): add getAll function to mysql service
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>
2024-04-25 12:18:33 +02:00
2210280edd
feat(services): update return types and add documentation in mysql service
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>
2024-04-25 12:11:17 +02:00
47adae9137
feat: Update MySQL service for category operations
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>
2024-04-25 12:01:02 +02:00
ef83ad18a4
feat(services): Db - category insert method
#6
2024-04-25 11:37:09 +02:00
adbecfa435
style(services): 🎨 Db 2024-04-25 11:36:20 +02:00
896b01f8b4
update 2024-04-24 16:57:09 +02:00
03d10ca675
fix(services): 🚑 User - multiple corrections on call of services 2024-04-24 16:56:55 +02:00
fa93b24ccc
build: 🐛 export renaming 2024-04-24 16:56:05 +02:00
95dd3f36bf
others... 2024-04-24 16:55:37 +02:00
6a54dd0afa
feat(services): Db - partial insert method for 'model' 2024-04-24 16:55:15 +02:00
956a6ca7af
build: 🐛 dependency fix 2024-04-24 16:54:22 +02:00
e995aaa970
refactor(interfaces): ♻️ Db - models 2024-04-24 16:53:49 +02:00
1ed1f018e8
fix(controllers): 🐛 auth - variables name change 2024-04-24 16:39:21 +02:00
ccee786c2f
feat(services): 🎉 db - models getters interaction
#7
2024-04-24 15:07:45 +02:00
69fae2b780
feat(services): db - user interaction
#4
2024-04-24 15:04:44 +02:00
1f984f4392
fix(services): 🐛 CredentialService missing namespace 2024-04-23 16:39:03 +02:00