137 Commits

Author SHA1 Message Date
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
88e89f0551
feat(database): update database schema and sql dialect settings
- 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>
2024-04-29 13:39:28 +02:00
9a6d7a73b2
feat(services): update getAvailable method in mysql.service
- 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>
2024-04-29 13:38:15 +02:00
89d9fc47b2
feat(database): update database configuration
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>
2024-04-29 13:09:54 +02:00
37cfaf4bbd
feat(services): implement getById and getAll methods in mysql service
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>
2024-04-29 12:23:13 +02:00
8138231112
feat(data-grip): Add new data source and schema metadata files
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>
2024-04-29 12:12:50 +02:00
edf2f6880c
feat(services): enhance insert and update methods in mysql.service.ts
- 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>
2024-04-29 12:05:34 +02:00
cd4b8479d2
fix(scripts): correct 'bun:dev' script in package.json
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>
2024-04-29 11:44:58 +02:00
d05c7efadc
feat(package.json): change main entry point and add development script
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>
2024-04-29 11:35:44 +02:00
8fe0fa57d8
feat(services): add Vehicle methods to mysql service
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>
2024-04-29 11:31:50 +02:00
2796b514eb
feat(routes): add BrandController methods to catalog routes
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>
2024-04-29 11:30:59 +02:00
0053c0ce19
feat(interfaces): add IDbVehicle interface
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>
2024-04-29 11:30:13 +02:00
041e77efcd
feat(controllers): include request param to getAll functions
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>
2024-04-29 11:29:29 +02:00
915b205b6e
chore(others): add mariadb to .gitignore
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>
2024-04-29 09:54:20 +02:00
4ff1aa852d
feat(app): add handling for app port from environment variable
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>
2024-04-29 09:54:04 +02:00
c024770b4a
feat(services): handle MySQL connection errors with process exit
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>
2024-04-29 09:53:18 +02:00
37ec62405e
feat(routes): update catalog routes with ModelController methods
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>
2024-04-29 09:52:43 +02:00
57151ec777
feat(controllers): add new TODO in model.controller
- 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>
2024-04-29 09:51:59 +02:00
0f8fd9a3e8
feat: Add Docker compose file for database setup
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>
2024-04-29 09:39:15 +02:00
80dff138cc
chore(others): add dist to .gitignore
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>
2024-04-26 16:22:30 +02:00
0887fe213f
feat(services): update JWT methods in jwt.service.ts
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>
2024-04-26 16:22:14 +02:00
3231f916f8
feat(validators): add check for non-existent userId
- 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>
2024-04-26 15:44:01 +02:00
a74731a49e
feat(controllers): add ModelController with CRUD methods
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>
2024-04-26 14:09:29 +02:00
9bdcdef88f
feat(routes): apply routers and rename files
- 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>
2024-04-26 12:21:13 +02:00
5d53cd28f8
refactor(services): update methods in ModelService
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>
2024-04-26 12:13:28 +02:00
8711b3530a
feat(services): add fetch functions for models
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>
2024-04-26 12:12:03 +02:00
13d72ad529
feat(services): update logging in updateModel and add deleteModel
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>
2024-04-26 12:06:19 +02:00
f23aabccd4
feat(services): add updateModel function and refine createModel function in model.service.ts
This commit mainly includes adding `updateModel` function, which updates a model in the database and refines `createModel` function in `model.service.ts`. It provides more clear explanations before the function and also specifies the return data type.

Issue: #27
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:58:04 +02:00
c70bcef352
feat(services): add model service
This commit adds a new service `ModelService` to handle model operations such as create, update, and delete. Some features like getBySlug, getAll, getById, getByCategory, and getByBrand are also introduced.

Issue: #27
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:53:42 +02:00
30bd5a0dbe
feat(services): update database operations return type in mysql.service
This commit includes significant changes in `mysql.service.ts` in the `services` scope.
- Imported `IDbStatusResult` type.
- Updated the return type of all operations (insert, update, delete) on both `Brand` and `Model`. These operations now return `Promise<IDbStatusResult>` instead of `Promise<unknown>` or `Promise<number>`.
- Also, adjusted the functions documentations to reflect these changes, providing more clarity about the returned result from database operations.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:34:15 +02:00
61c546459a
feat(interfaces): add IDbStatusResult interface
A new interface, `IDbStatusResult`, has been added to the 'interfaces' scope. This interface includes details about database operations such as field count, affected rows, insert id, info, server status, warning status, and changed rows.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:18:41 +02:00
adaf4e30db
feat(services): update MySQL services with method adjustments
- Modified 'getById' reject message for accuracy.
- Adjusted 'getBySlug' method parameters for clarity and renamed the field used in the SQL statement.
- Added a new 'getById' method for retrieving models by ID.
- Updated the 'insert' method to correctly insert data into the `models` table.
- Refactored 'getBySlug' method for categories, renaming the parameter and making error messages more precise.

Issue: #7
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 11:09:26 +02:00
2f4ad31edf
docs(controllers): add TODO comment for future feature in brand controller
In the brand controller file, a comment was added indicating a future enhancement to implement the functionality that fetches all models of a specific brand.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 10:29:07 +02:00
c25b204c67
feat(controllers): add BrandController with CRUD operations
This commit introduces a new `BrandController` in the controllers folder, offering key Create, Read, Update, and Delete (CRUD) operations. This includes `createBrand`, `updateBrand`, `getBySlugBrand`, `getAllBrand`, and `deleteBrand` methods, providing better control and operation of brands within the application.

Issue: #14
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 10:26:38 +02:00
0a6321deb0
feat(services): mark blob validation as TODO in brand service
A TODO comment has been added to the `brand.service.ts` file indicating that blob validation needs to be implemented in the future, for both the 'create' and 'update' functions in the brand service.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 10:00:55 +02:00
a811a2ece2
docs(services): add tasks to MySQL and Category services
An additional task is marked in the MySQL service to check if models are linked before taking further actions. Similarly, in the Category service, two tasks are added to verify the existence of a category and elements linked to it before proceeding with deletion.

Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:57:44 +02:00
85adbbcdb3
docs(services): add new tasks in brand.service.ts
A couple of new tasks have been added into the `brand.service.ts` file.
The tasks aim to fetch models and stats of a certain brand.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:53:27 +02:00
5c0d266002
feat(services): add deleteBrand function to brand.service.ts
The `brand.service.ts` file is updated to include a new function `deleteBrand`, which allows a brand to be deleted from the database by its ID. Appropriate error handling and activity logging have been incorporated to ensure smooth operation.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:52:09 +02:00
6c626e0b18
feat(services): add getByIdBrand function in brand service
A new function, `getByIdBrand`, has been added to the brand service. This function retrieves a brand from the database based on the provided brand ID, Checks are performed on the brand ID before the retrieval attempts.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:41:37 +02:00
aecaf83d85
feat(services): add getBySlugBrand function in brand.service
Adds a new function `getBySlugBrand` in `brand.service.ts`. This function retrieves a brand by its slug, providing a more specific search option. It implements error logging for missing slug or brand not found scenarios, and successful retrieval of the brand.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:40:24 +02:00
33d44ee4b6
feat(services): add getAllBrand function in BrandService
The BrandService in the services module now includes a new functionality - the getAllBrand function. This function retrieves all brands from the database. Loggers have been added to check successful retrieval and error handling.

Issue: #13
Signed-off-by: Mathis <yidhra@tuta.io>
2024-04-26 09:35:55 +02:00