18 Commits

Author SHA1 Message Date
baecabc93a
feat(databases.service): add user editing function and disable MongodbService
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.
2024-05-22 14:20:55 +02:00
c9e6cb6169
feat: add authentication middleware
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.
2024-05-22 14:20:30 +02:00
1ad136ea60
feat: Implement registration feature and update database service
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.
2024-05-21 16:14:54 +02:00
18c20c52d5
feat(authentication): create credentials service
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.
2024-05-21 14:02:21 +02:00
8d7d8d750d
feat: Add MariaDB interfaces for User and Follow
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.
2024-05-15 14:23:55 +02:00
9302df4b0f
feat: Add IntCode service in authentication
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.
2024-05-15 14:23:40 +02:00
2eda06f087
feat(authentication): add JWT service for sign and verify operations
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.
2024-05-15 12:00:40 +02:00
23aad51699
feat: Add converters utility file
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.
2024-05-15 11:44:11 +02:00
064b51e0bd
chore: Add ellipsis to users fetching log message
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>
2024-05-15 09:37:39 +02:00
Mathis
b72e715d0f
feat: add promise callback to getAllUsers method call
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>
2024-05-15 09:32:51 +02:00
Mathis
9c45029706 feat: Add DatabasesService in services/databases
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.
2024-05-14 23:35:11 +02:00
Mathis
6b944301cc feat: Update regex for email and username validation
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.
2024-05-14 23:34:49 +02:00
Mathis
9c97420027 refactor: Update service dependency and logger names in app.ts
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.
2024-05-14 23:34:09 +02:00
39b4bfc022
feat: Add MariaDB service and validators utility, refactor MongoDB service, and update configs
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.
2024-05-14 16:52:20 +02:00
02224e0727
feat: Add environment utility and MongoDB services
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.
2024-05-13 16:54:01 +02:00
2b53168dd9
feat: set up basic express server configuration
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.
2024-05-13 16:52:50 +02:00
24101f53fa
feat: Add new logging utility class
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.
2024-05-13 14:28:12 +02:00
806eb3e183
feat: Add new file
A new file has been added to the project. The change includes setting the unique mode to 100644.
2024-05-13 09:39:14 +02:00