The commit includes the addition of an `editUser` function in `databases.service.ts` that allows users to edit their details. Also, `MongodbService` has been commented out and the getUserById function now takes in a string instead of a number for the userId. The function will need to be tested for its successful implementation.
This commit adds authentication middleware for user and admin levels. The middleware retrieves the JWT from the header and verifies it. Error messages are returned for cases like no token found, user not found, unverified email, and when a user is not an admin but tries to perform an admin function.
This commit creates new methods for the authentication system, especially the user registration feature. The update also validates input data and checks if a user already exists in the database. It modifies the application entry point to include the updated user registration route and provides updates to the database service to include user-related functions. The MariaDB collation was also updated in the database schema script to support unicode.
A new credentials service has been created with two main functionalities: hashing a password and comparing an original password with a hash. These methods use the Argon2id hashing function and are intended to be part of the authentication process.
This commit introduces definitions for UserInDatabase and FollowInDatabase interfaces. These interfaces will provide a strict typing for objects retrieved from MariaDB, ensuring consistency and decreasing potential runtime errors.
Implemented a new IntCode service within the authentication services. The service is responsible for generating a 6-digit random integer code using the randomatic module. This service will be used for OTP functionalities.
This commit includes a new JWT service for handling JWT signing and verification. It leverages utility functions for logging and environment variable handling. The signed JWT tokens cater to protected header parameters and adjustable expiration times. Moreover, this service supports JWT verification with transparent handling of verification failures.
This commit introduces a new utility file for various data conversions. This new file, converters.util.ts, includes functions to convert case for strings and convert between boolean values and buffers.
This commit adds an ellipsis to the log message displayed when fetching users from the database, to indicate that the operation is in progress. This small change improves the readability of the logs and clarity of operations status.
Signed-off-by: Mathis <avnyr@yidhra.fr>
This commit adds an empty then() callback to the getAllUsers method call to handle the returned promise. This is typically followed by actual actions in production to handle the promise resolution.
Signed-off-by: Mathis <mherriot@yidhra.fr>
Implemented new class DatabasesService for handling database interactions in place of multiple database services. This centralizes the interaction with different databases - MariaDb and MongoDB with added logging utility for monitoring query results. Also, a test instance of the DatabasesService was created as 'justForTesting' for development purposes.
Updated the regex in 'isEmail' and 'isUsername' validators to adjust valid string length. It now allows for a shorter username and a longer domain in email addresses.
This commit simplifies the database service dependency by importing 'justForTesting' method from the simplified databases.service. It also renames the logger instance and environment files from "App" to "OnlyDevs". Removed unnecessary test function using mongo and mariadb services.
This commit introduces several changes:
- A new MariaDB service is implemented including connection handling and query execution.
- Field validators (email, username, password) are added to utils.
- The MongoDB service is refactored by moving the connect method into the constructor.
- The "noDelete" configuration field is updated in biome.json.
- A new interface is added for factorizing data into SQL queries.
- The app.ts file is updated to include the MariaDB test alongside MongoDB.
Two new classes have been added: EnvUtils and MongodbService. EnvUtils provides functionality for fetching environment variables and logging them. MongodbService implements connection to MongoDB with user credentials fetched from environment variables. Additionally, some updates have been made to logs.util.ts to improve logging style and biome.json for better code standards adherence.
This commit adds different middlewares to the express server such as cors, helmet for security, json and url-encoded body parsers, and gzip compression. Additionally, server start logic including router configuration and MongoDB service instantiation are also handled.
The commit introduces a LogsUtils class under src/utils. This class includes various logging methods such as info, warn, error, softError, trace, fatal, and debug. Also, it uses conditional statements to handle different context and debug scenarios.