A logging feature is added in the `rent.service.ts` to log any errors when attempting to delete rent. This feature helps in diagnosing issues during rent deletion.
Issue: #24
Signed-off-by: Mathis <yidhra@tuta.io>
The minimum size for the TypeScript language in the duplicated code check has been increased. This update reduces the sensitivity of the code redundancy inspection, potentially reducing false positive results.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit introduces new functions to handle rental services in the src/services/rent.service.ts. Functions created handle rental CRUD operations such as createRentService, updateRentService, deleteRentService, also additional utility functions such as getUserRentService and getRentByIdService that deal with user-associated rentals were introduced. These new functions serve to simplify rental management and improve our services for rental handling.
Issue: #24
Signed-off-by: Mathis <yidhra@tuta.io>
- Update the getById method in mysql.service to return an array of vehicles instead of a single vehicle
- Add a new getById method to retrieve array of rental information by rental ID
- Improve the documentation to match the modifications in both methods' functionalities
Issue: #23
Signed-off-by: Mathis <yidhra@tuta.io>
This commit hooks up the `VehicleController.create` function to the route handling post requests at `/veh/new`. With this change, admin users can add new vehicles via this endpoint.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit adds an `update` function to the `mysql.service.ts`. This new function will update a rent record in the database. It takes a database handler object and a rent object containing the updated data, and returns a Promise that resolves to the status result of the update operation. The function will throw an error if an issue occurs during the update operation.
Issue: #23
Signed-off-by: Mathis <yidhra@tuta.io>
This commit includes the following changes in `mysql.service.ts` file:
- Simplify SQL query strings for `UPDATE` and `INSERT` commands in various methods to make them more readable.
- Reformat parameters in `getAllModelsFromCategory` and `delete` methods for better readability.
Signed-off-by: Mathis <yidhra@tuta.io>
Update `rentRouter.ts` to include `VehicleController` methods in route handlers.
- Add `VehicleController.getAll` to "/veh/all" route.
- Update "/veh/:vehicleId" route to include `VehicleController.getById`, `VehicleController.update`, and `VehicleController.delete`.
Issue: #22
Signed-off-by: Mathis <yidhra@tuta.io>
Added a new `vehicle.controller.ts` file under controllers. It includes multiple functions related to vehicle management such as `createVehicle`, `updateVehicle`, `getAllVehicle`, `getVehicleById`, `getAvailableVehicle`, and `deleteVehicle`. These functions handle the creation, updates, retrieval, and deletion of a vehicle respectively. With these additions, the application now has the ability to manage vehicles through the `VehicleController` module.
Issue: #22
Signed-off-by: Mathis <yidhra@tuta.io>
- Modify import statement format and standardize indentation across the entire file.
- Add line breaks and commas where needed for better readability.
- Remove unnecessary comments and white space.
- Ensure consistent usage of semicolons.
Signed-off-by: Mathis <yidhra@tuta.io>
In this commit:
- Implemented factorize method to standardize data processing and update operations for users, brands, models, categories, and rents.
- Updated SQL syntax to improve code hygiene and readability.
- Added debug mode checks to improve performance in production.
- Added exception handling for possible errors during SQL query execution.
- Added additional methods to get assigned vehicles to a user and all assigned vehicles from the database.
- Added missing delete method for vehicle and rent tables.
Issue: #23 & #21
Signed-off-by: Mathis <yidhra@tuta.io>
A new optional `id` property has been added to `IDbRent` interface in the `interfaces` scope. This allows for more flexibility when working with rent objects in the database.
Signed-off-by: Mathis <yidhra@tuta.io>
The database table `rent` has been renamed to `rents` to better align with naming conventions. The related DROP TABLE and CREATE TABLE commands have been updated accordingly in `db.sql`.
Signed-off-by: Mathis <yidhra@tuta.io>
A new function `deleteVehicleService` is added to `vehicle.service.ts` to handle the vehicle deletion process. It will return true if the operation is successful, and false if it fails or encounters an error.
Issue: #21
Signed-off-by: Mathis <yidhra@tuta.io>
Implemented `getAllVehiclesService`, `getVehicleByIdService` and `getAvailableVehicleService` in `vehicle.service.ts`. Each of these services fetches respective data from the MySQL database, handles errors, and returns the data along with a timestamp.
Issue: #21
Signed-off-by: Mathis <yidhra@tuta.io>
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>
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>
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>
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>
- 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>
- 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>
- 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>
- 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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
- 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>
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>
- 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>
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>
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>
- 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>
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>
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>
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>
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>
- 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>
- 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>
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>
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>
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>
- 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>