177 Commits

Author SHA1 Message Date
f310bedeff
feat(services): add vehicle update functionality in vehicle.service.ts
An `updateVehicleService` function has been introduced in `vehicle.service.ts` to enable vehicle data updates in the application. The function handles data validation, updates the MySQL database, and logs the process status.

Issue: #21
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 16:39:50 +02:00
838ea4ad22
feat(services): add new vehicle service
This commit introduces a new file `vehicle.service.ts` which includes a function for creating new vehicles. It uses MySQL service for data handling and includes error handling and logging functionalities. The changes help in improving the code modularity and providing a specific service for vehicle management.

Issue: #21
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 16:37:28 +02:00
00064fd054
feat(controllers): tag functions to test in auth.controller.ts
Marked several functions in `auth.controller.ts` file with `//ToTest` comments indicating that these functions are ready for testing. The tagged functions are `getAllUsers`, `getUser`, `editUser`, `deleteUser`, `deleteSelf` and `getSelf`. This is important for ensuring that all these features function as expected.

Issue: #19
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 16:13:46 +02:00
70a6e5df54
refactor(controllers): enhance error handling in auth controller
Update error handling in `auth.controller.ts` to provide more accurate responses based on operation results. This includes rigorous checking of response types before proceeding with particular operations. Notable changes include switching from string errors to error codes, and ensuring necessary properties exist in objects before accessing them.

Issue: #19
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 16:12:21 +02:00
7f52a9d75e
feat(controllers): improve response error handling in auth.controller
- Improve error handling in methods of the `auth.controller`
- Refactor conditional checks for errors to handle non-string types and missing payload data.
- Update response error messages to be more consistent and informative.

Issue: #19
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 15:41:38 +02:00
62742e6afe
feat(services): update user service
- Moved import statement to top for better organization.
- Removed unnecessary comments and lines.
- Simplified return statements for clarity and efficiency.
- Streamlined deletion process by directly returning the result.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 15:40:48 +02:00
bdfc598218
feat(services): update user service dynamic types and enhance error handling
- Refactored `editUserService` function to use `IUserUpdate` type for `inputData` instead of `IDbUser`.
- Enhanced error handling in `editUserService` and `deleteUserService` by checking for affected rows in the returned result.
- Updated `deleteUserService` from using MongoDB method to MySqlService method.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 15:37:39 +02:00
1cbc771251
feat(app): update debug syntax, refactor HTTP status codes
- Updated import and usage of `isDebugMode` function across multiple controllers and services for better readability
- Improved the use of HTTP status codes in `auth.controller.ts` for more accurate responses
- Refactored HTTP status codes `HttpStatusCode` enum to include detailed comments

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 15:29:19 +02:00
8644b5add6
feat(services): update user.service.ts for better error handling and debugging
The updated `user.service.ts` now includes better error handling using optional chaining and also generates a JSDoc definition for HTML status codes. An extra logger trace has also been added, which provides token related information in debug mode. This will capture user login token details for debugging purposes. Also cleaned up code formatting for readability.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 15:28:45 +02:00
b66a5aff6d
feat(interfaces): add HttpStatusCode enum
Added a new file `HttpStatusCode.ts` in the `interfaces` scope. This file defines an enum which represents all the possible HTTP Status Codes, enhancing readability and maintainability in the code base by replacing hard-coded numbers with meaningful names.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 14:37:46 +02:00
3d3da77df0
feat(services): add getByEmailService to user.service.ts
A new method `getByEmailService` has been added to `user.service.ts`. This method retrieves a user from the database by their email. The tracing log adjustment has also been performed, where logging only happens when it's in debug mode. If there are multiple users with the same email, this method will return the first user.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 14:25:10 +02:00
abaeafea8a
feat(services-controllers): implement debug mode and refactor error handling
- Implement debug mode for logging in services and controllers.
- Improve the precision of memory usage information in the app by rounding.
- Refactor error handling in services, notably in user service register function for better error checking.
- Include a condition in the AdminGuard validator to check if the token is valid.
- Fix issue in auth controller that was misidentifying user registration error as a successful registration.
- Refactor log display in Mysql service error throwing for better readability.
- Refactor memory usage information display in app for better readability.

These changes aim to improve the clarity of logs and accuracy of error reporting for a better debugging experience. The implementation of debug mode gives more control over the information displayed in the development phase. Several fixes in error handling also contribute to a more robust system.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 14:18:28 +02:00
cb41c68f77
feat(utils): add debug state utility
This commit includes the creation of a new utility file for checking if the app is running in debugging mode. It exports `isDebugMode()` function that checks the `DEBUG` environment variable's value.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 14:11:48 +02:00
e98729c9e5
style(app): Remove newline from memory usage logging
This commit modifies the logging of memory and heap usage in the app.ts file. The redundant newline code `\n` at the end of the log message has been removed to enhance readability and neatness of the logs.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 13:31:56 +02:00
cd09a0c61b
build(others): update TypeScript compiler options in tsconfig.json
This commit updates the TypeScript compilerOptions in tsconfig.json. The changes include higher module resolution targets, adjustments in various compiler constraints, and the modification of paths for baseUrl. This will help improve the code's compile-time and run-time behavior.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 13:12:54 +02:00
1723a8588a
feat(controllers): update registerUser function in auth controller
This commit includes changes to improve the `registerUser` function in auth.controller.ts.
- Switched registration from displayName to email and added email validation
- Adjusted types and logging for better consistency and readability

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 12:23:20 +02:00
3fe6453b0c
style(utils): improve code readability in email validator
Improved code readability by formatting the regular expression in the `isEmail` function in `utils/validators/email.ts` and also ensured a newline at the end of the file.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 12:23:05 +02:00
98477c5f27
feat(interfaces): update user and request interfaces
- Renamed `is_mail_verified` to `is_email_verified` in `IDbUser`
- Replaced `username` with `email` in `IReqLogin`
- Commented out `dob` in `IReqRegister`
- Added new field `_questionMarksFields` in `IDbFactorize`

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 12:22:43 +02:00
3472c59ac2
feat(services): refactor MysqlHandler to improve factorize method
Update the MysqlHandler class in the 'mysql.service.ts':
- Enhance the `factorize` method to handle 'id' in a special manner and create a string of '?' for prepared SQL queries.
- Refactor the `add` method to utilize the updated `factorize` method for constructing SQL queries.
- Update the return types of `getById` and `getByEmail` methods to return an array of IDbUser instead of a single IDbUser instance.
- Rename a private attribute 'Logger' to 'logger'.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 12:22:17 +02:00
3b6726113d
feat(services): enhance user service functions
- Modified the logic in `getUserByEmail` to handle multiple user instances.
- Altered the dob field to save as current date in inserted user records.
- Richened `getByEmailService` function to check email existence in the database.
- Adjusted `is_mail_verified` flag to `is_email_verified` within user insertion function.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 12:21:37 +02:00
d78b0aec4c
feat(utils): add email validator function
A new function `isEmail` has been added to the utils folder that validates if a given string input is a valid email address. This should help in reducing erroneous entries and improve data validation.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-05-02 09:59:51 +02:00
ae6b25fbd6
style(services): improve code readability in user.service file
The user.service has been reformatted for better readability. Changes mainly include adding new lines and spaces to make the code more structured. No change in logic involved, purely cosmetic.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:52:23 +02:00
d7f9cb0b37
feat(services): enhance readability and update factorize function for various elements in mysql.service
- The readability within mysql.service.ts file is improved by formatting multi-line functions.
- The factorize function for 'users', 'brands', 'vehicles', and 'categories' has been updated to enhance code quality.
- Import statements were restructured for better readability.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:51:55 +02:00
cb1c2ee87c
feat(interfaces): add newline at end of IDbFactorize file
A newline has been added at the end of the `IDbFactorize.ts` file to conform to coding style conventions.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:51:13 +02:00
23ce32cb6f
feat(services): refactor update methods in mysql service
This commit:
- Standardizes the data handling in all update methods, using `handler.factorize()`
- Moves gdpr date validation to the top of 'update' method to reject it earliest
- Removes the unused `_values` and `_template` variables.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:50:40 +02:00
f6d18fc58d
feat(services): simplify SQL query keys generation in mysql service
Remove the condition to check 'id' while generating SQL query keys in the `mysql.service.ts`. Now, a map function is used directly resulting in cleaner and leaner code.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:39:43 +02:00
5163d79056
test(services): add DbHandler usage in user.service.ts
This commit includes:
- The usage of `DbHandler.factorize` with sample values
- Testing log trace to monitor the result and fields of factored user data

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:36:59 +02:00
ea3b7aa68b
feat(services): prevent id field from being factorized in mysql service
In the `mysql.service.ts`, the `factorize` function has been updated to exclude the `id` field. This change ensures the 'id' field is not injected into the result to avoid any potential issues. Furthermore, The update operation in the same file has been refactored to use the updated `factorize` function, hence enhancing code reusability.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:35:51 +02:00
bc12f94e41
feat(services): refactor user service and improve error handling
- Introduced error handling in `register`, `login`, `getAllUsersService`, and `editUserService` methods.
- Improved logging by adding breaks for better visibility.
- Refactored code for better readability and maintainability.
- Eliminated unnecessary and duplicate imports.
- Transitioned from MongoDB to MySQL service.
- Added comment flags for testing purposes.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:19:12 +02:00
df28d3aa52
feat(services): add factorize method and refactor update method in mysql.service
- The `factorize` method was added to `mysql.service.ts` to convert input data into a database query.
- The `update` method was refactored; unnecessary data fields were removed and a check for the `gdpr` field was added. A corresponding interface, `IUserUpdate`, was also imported at the beginning of the file.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:15:19 +02:00
3d5ea6ac30
feat(interfaces): add IUserUpdate interface
This commit introduces a new interface named IUserUpdate. This interface consists of optional properties like id, username, firstname, lastname, dob and gdpr. These properties are used for validating user's data during update operation.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:14:47 +02:00
2fb6cd6e83
feat(interfaces): add IDbFactorize interfaces
Added IDbFactorizeOutput and IDbFactorizeInput interfaces to handle inputs and outputs of the SQL query factorization function. Both interfaces contain various properties for customizing the SQL query and its error handling behavior.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 16:14:29 +02:00
34f028ef9f
feat(app): updated log messages in multiple files
Changes applied to several services and controllers files:
- Enhanced logging messages with line breaks in `brand.controller.ts`, `auth.controller.ts`, `model.controller.ts`, and `category.controller.ts`.
- Adjusted logging in `mysql.service.ts`, `brand.service.ts`, `user.service.ts`, `category.service.ts`, `model.service.ts` and `jwt.service.ts` to commence on a new line for better readability.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 14:18:47 +02:00
0635c512cc
feat(services): add memory usage info, update user, enhance log and register function
- Added log for loaded services
- Implemented feature to update user in MySQL service
- Added memory usage information in the server start log
- Enhanced registration function in user service to provide more detailed response and log information
- Minor code formatting improvements

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 14:08:00 +02:00
3232e5fac1
feat(services): improve UserService with enhanced error handling and data validation
This commit includes updates to `user.service.ts` that enhance error handling and data validation. The `getUserFromUsername` function has been renamed to `getUserByEmail` reflecting the new identifier being used to retrieve users. Both `getUserByEmail` and `getUserFromIdService` have been revised to include error handling and logging capability. The `register` function now incorporates stronger validation checks and proper GDPR verification. It is also updated to return JWT token on successful registration.

Issue: #18
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 12:38:26 +02:00
9225337e95
feat(interfaces): update IReqRegister interface
The `IReqRegister` interface was modified. It no longer includes the `displayName` field, but `dob`, `email`, and `password` fields were added. The 'password' property was moved to the end of the interface.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 12:37:24 +02:00
f1272ca2c8
refactor(interfaces): remove unnecessary quotes in ErrorType enum
Removed unnecessary quotes from the keys of the `ErrorType` enum in the `ISError.ts` file, making the code more readable and conforming to TypeScript's best practices.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 12:35:27 +02:00
4fd6c11326
feat(interfaces): add ISError interface and ErrorType enum
A new interface `ISError` has been added to represent error objects. Also, an enumeration `ErrorType` has been included to cover all possible types of errors that may occur in the application. This improves the structuring of error handling in the project.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 11:57:22 +02:00
355cb0ec90
refactor(services): refactor method arguments and promises handling in mysql.service.ts
- Compact multiple lines codes into single lines for readability and simplicity.
- Replace some Promise responses from unknown to specific IDbStatusResult for a more predictable result.
- In `insert`, `update`, `getById` and `delete` methods for `brands`, `categories`, `models`, `vehicles` and `users`, modify the way promises are handled and return values.
- This makes the code more readable and easier to understand.

Issue: #17
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 11:42:05 +02:00
19d265a0e6
refactor(services): simplify function calls and logging statements in user.service.ts
This commit simplifies multi-line function calls and logging statements in `user.service.ts` to be just single-line. This change enhances the readability and maintainability of the code by reducing unnecessary lines and making the function calls and logging statements more straightforward.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 11:05:34 +02:00
a6593cb76f
feat(all): refactor code for readability and simplicity
The controllers, services, routes, and others have been updated to reduce code complexity and improve readability. Changes include removing unnecessary lines, replacing long function signatures with simpler versions, and streamlining condition checks and logger statements.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 11:03:28 +02:00
28671146d1
feat(others): Add BiomeSettings in .idea/biome.xml
A new file `.idea/biome.xml` is added with `BiomeSettings` component for the project. It also includes MANUAL configuration with enabling formatOnSave option.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 10:56:39 +02:00
56bfd8cd0d
type: style
scope: services, interfaces

subject: Apply code formatting

- Correct indentation and formatting to match code style standards in multiple 'interfaces' and 'services' files.
- Also ensure lines at the end of the files.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 10:55:37 +02:00
cda313866f
feat(services): update return type in mysql.service
The return type for the update function in mysql.service is updated from Promise<unknown> to Promise<IDbStatusResult>. Also, the function resolves with the status result of the update instead of just being successful.

Issue: #17
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 10:01:14 +02:00
91b88ea592
chore: Bump package version to 1.1.0
The package.json file has been updated, specifically the version of the project has been changed from 1.0.0 to 1.1.0.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 09:59:24 +02:00
44b5745f3b
feat(services): update insert function in mysql service
The `insert` function in mysql service has been updated. The function now includes more accurate commenting, and a check for `id` validity. It now returns a Promise with `IDbStatusResult` instead of `unknown`. The changes improve function clarity and error handling.

Issue: #17
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-30 09:59:06 +02:00
a9cf48b04a
docs(services): update MySqlService in mysql.service.ts
Added a comment to test all users in MySqlService. Also, removed a redundant comment in Vehicle's MySqlService. All changes are seen in mysql.service.ts.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-29 15:00:33 +02:00
16a8e892f9
feat(others): Update database collations
The collations in the database have been updated, changing from `armscii8` to new ones such as `big5`, `dec8`, `cp850`, and others. This should help to smooth internationalization and localization processes involving different charsets.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-29 15:00:04 +02:00
89ba2cb6d1
feat(others): add new SQL dump file
The `db.sql` file was newly created which contains the structure for several tables namely `brands`, `categories`, `models`, `rent`, `users`, and `vehicles`. The tables contain relationships and constraints among them and is a MariaDB dump prepared for a Linux system.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-29 14:58:44 +02:00
47bb7aacdf
refactor(services): add IDbVehicle import in mysql.service.ts
This commit includes changes to the import lines in 'mysql.service.ts'. Import of 'IDbVehicle' from '@interfaces/database/IDbVehicle' has been moved to maintain alphabetical order of the imports.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-29 13:40:46 +02:00