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>
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>
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>
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>
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>
- 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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
- Added new procedures `CheckVehicleAvailability` and `IsVehicleAvailable` to the database schema.
- Introduced an `isAvailable` column to the `vehicles` table.
- Updated sql dialect settings to include a new console file for the database.
- Reflected changes also include id adjustments and table modifications.
Signed-off-by: Mathis <yidhra@tuta.io>
- Transform `getAvailable` method into a promise that retrieves available vehicles from the database.
- This method now takes the MySQL handler object to execute the query and returns a promise that resolves to an array of available vehicles.
- It also handles error while executing the query.
Issue: #20
Signed-off-by: Mathis <yidhra@tuta.io>
Update the database configuration like updating the LastIntrospectionLocalTimestamp and refactoring indexes and keys. This includes adding two new indexes `users_pk` and `users_pk_2`, and corresponding keys. Moreover, the columns' ID have been updated. These changes are done for better database performance and clear structuring.
Signed-off-by: Mathis <yidhra@tuta.io>
Implemented getById and getAll methods in the mysql service. The getById method retrieves a vehicle by its ID, and the getAll method fetches all vehicles from the database. These improvements facilitate more efficient data retrieval and enhance overall service functionality.
Issue: #20
Signed-off-by: Mathis <yidhra@tuta.io>
Two new files have been added: `brief_05.6nelCw.meta` for schema metadata, and `1f2800b5-8649-4a80-a9ec-b7b2a24623b4.xml` for defining the data source. These configurations support the interaction with our database in different environments.
Signed-off-by: Mathis <yidhra@tuta.io>
- Enhanced `insert` and `update` methods in `mysql.service.ts`
- Added detailed documentation and type checks for `insert` function.
- Implemented body of `update` method, included parameter validation and SQL query building.
Issue: #20
Signed-off-by: Mathis <yidhra@tuta.io>
The previous `bun:dev` script was missing the key command `bun run`. This has been corrected for proper execution of the script in the development mode.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit modifies the `package.json` file in two key ways. The main file is now `src/app.ts` instead of `dist/app.js`. Additionally, a new script `bun:dev` has been added to aid in development, which watches the main file for changes.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit introduces several new Vehicle methods to the mysql service (insert, update, getBySlug, getAll, getAvailable, getDue). These methods are scaffolded but not fully implemented, with `insert` being the most complete at this stage.
Issue: #20
Signed-off-by: Mathis <yidhra@tuta.io>
The commit introduces BrandController methods to the catalog router. Specifically, it implements create, getAll, getBySlug, update, and delete functionalities for brand routes. This update enhances brand management within the catalog.
Signed-off-by: Mathis <yidhra@tuta.io>
Add a new interface called `IDbVehicle` in the interfaces module. The `IDbVehicle` interface includes properties such as `id`, `plate_number`, `model_id`, `odometer`, and `health_state` for defining a vehicle object in our database.
Issue: #20
Signed-off-by: Mathis <yidhra@tuta.io>
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 .gitignore file was updated to ignore the `mariadb` file, preventing it from being tracked by version control. This ensures database related elements are ignored for smoother version control operations.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit imports the `process` module from `node:process` and changes the app to listen on a port specified by an environment variable (APP_PORT). It also adds an error handler to stop the server and log the error message if the server fails to start.
Signed-off-by: Mathis <yidhra@tuta.io>
Updated `mysql.service.ts` to handle MySQL connection errors by terminating the process instead of throwing a generic error. This change provides a more direct response to database connection failures.
Signed-off-by: Mathis <yidhra@tuta.io>
A ModelController has been imported and its methods applied to the catalogue routes in the system. The changes include methods for creating, getting all, getting by slug, updating, and deleting models. Prior routes have been updated and enhanced with these additional controller methods for improved performance.
Issue: #28
Signed-off-by: Mathis <yidhra@tuta.io>
- The code update adds a new `TODO` comment in the `model.controller.ts` file.
- The new `TODO` is about getting a model with available vehicles.
Issue: #28
Signed-off-by: Mathis <yidhra@tuta.io>
Add a `docker-compose.yml` file to ease local development. The file specifies configuration for a MariaDB container that will now serve as our database server. Environment variables and ports are also configured in the file.
Signed-off-by: Mathis <yidhra@tuta.io>
The update now includes `dist` directory in the `.gitignore` file to avoid pushing compiled files to the repository.
Signed-off-by: Mathis <yidhra@tuta.io>
Update the methods related to JWT in `jwt.service.ts`. Import and utilize `jwtVerify` and `SignJWT` from the "jose" package, replacing their previous counterparts. This refactors the `JwtVerifyService` and `JwtSignService` functions for better JWT handling.
Issue: #30
Signed-off-by: Mathis <yidhra@tuta.io>
- The `UserGuard` now checks whether the `userId` extracted from the token exists.
- If the `userId` does not exist, an error is logged and a response with the 'Unauthorized' status is returned.
Signed-off-by: Mathis <yidhra@tuta.io>
This commit adds a new controller, `ModelController`, to the controllers directory. This controller includes create, read, update and delete (CRUD) methods for handling 'model' related operations. Each method incorporates appropriate error handling and logging.
Issue: #28
Signed-off-by: Mathis <yidhra@tuta.io>
- Routers `AuthRouter`, `CatalogRouter`, and `RentRouter` are used in the application in `src/app.ts` with error handling.
- The router files under `src/routes/auth`, `src/routes/catalog`, and `src/routes/rent` are renamed to `authRouter.ts`, `catalogRouter.ts`, `rentRouter.ts` respectively.
- The default exports in these router files have been updated to reflect their new names.
- The imports in `src/routes/index.ts` are updated according to the renamed files.
Signed-off-by: Mathis <yidhra@tuta.io>
Removed `getByIdModel`, `getByCategoryModel`, and `getModelsByBrand` methods. These changes are to refine the methods available in ModelService for better usage and understanding.
Issue: #27
Signed-off-by: Mathis <yidhra@tuta.io>
Added two new functions, `getBySlugModel` and `getAllModels`, to the `ModelService` in `model.service.ts`. `getBySlugModel` fetches a model based on its slug while `getAllModels` fetches all models from the database.
Issue: #27
Signed-off-by: Mathis <yidhra@tuta.io>
The `updateModel` function's logging has been updated to use `slug_name` instead of `id`. Additionally, a new function `deleteModel` has been added to remove models from the database based on their slug. This function checks the existence of a model before attempting deletion and logs the process.
Issue: #27
Signed-off-by: Mathis <yidhra@tuta.io>