44 Commits

Author SHA1 Message Date
0028d2fb50
fix: switch to double quotes in setIssuer method in jwt.service
This commit changes the use of backticks for the setIssuer function in the jwt.service to use double quotes. This aims to maintain code consistency and align with the standard syntax conventions in the codebase.
2024-05-24 11:39:42 +02:00
3b3fc782b4
refactor: simplify logger methods in logs utility
This commit simplifies the method calls in the Logger utility. The multi-line method calls were unnecessarily complex, these have been refactored into single line calls for ease of reading and simplicity, doing away with superfluous code.
2024-05-24 11:38:55 +02:00
9b9732c9d1
perf: simplify registerService return on failure
Simplified the return statement structure of the registerService function. Removed an unnecessary else clause and returned failure directly instead for better readability and cleaner code structure.
2024-05-24 11:38:34 +02:00
a0b9b10bb4
refactor: use static string for MongoDB connection error log
The error message displayed when the MongoDB connection fails has been changed to use a static string. This is a small refactoring change that can result in more predictable log messages and easier debugging.
2024-05-24 11:37:34 +02:00
f4c74b129a
refactor: standardize error message in mariadb.service.ts
Updated logging messages in MariaDB service file. Removed template literals in logging and replaced them with standard strings for consistency and readability. Made adjustments in connection error messages and query execution error messages.
2024-05-24 11:23:03 +02:00
8620ccb167
docs: Add 'ToTest' annotations and extend logging in database service
This commit introduces 'ToTest' annotations to all methods in the database service. Furthermore, it extends the logging for specific functions, and includes an updatePost method for MongoDB interactions. These changes aim to improve code readability, debugging capabilities, and our database interactions.
2024-05-23 15:51:41 +02:00
8e14bf77b4
refactor: reorganize code and enhance readability
Code imports rearranged and updated for better consistency. Missing semicolons were added in multiple files to improve code readability and standards compliance. The usage of whitespace and indentation was also standardized across multiple files to improve overall code clarity.
2024-05-23 12:31:57 +02:00
b640dc7671
feat: Add getSelf endpoint and improve user service
This commit introduces a new endpoint, `GetSelfController`, for fetching authenticated user information in the `AuthController`. It also improves token handling by refactoring token retrieval from headers into a utility function. Additionally, the User service has been extended with new methods for getting a user by ID and for fetching follower and following information. Token UUID handling during registration has been tweaked for consistency. Improvements in logging levels and responses status codes have been made as well.
2024-05-22 17:04:41 +02:00
cb7a396636
docs(controller): add comment for future image handling
A comment section has been added to the 'auth.controller.ts' file to advise the development of image handling functionality in the future. The comment is placed right after the error handling for unsuccessful user registration attempts.
2024-05-22 14:22:06 +02:00
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
4082f96ebd
chore: update volume paths in docker-compose.yml
The docker-compose file has been updated to shift the persistence directory for MongoDB and MariaDB to a subdirectory under ".data". This change groups persistent data in a central location, making it easier for managing and backing up data.
2024-05-15 11:02:46 +02:00
6f2b4d0f91
feat: add timezone setting to data source
A timezone setting has been added to the dataSources.xml file. This change is for addressing any potential issues related to time manipulation that may arise due to the difference in time zones. Specifically, the timezone was set to "Europe/Paris".
2024-05-15 11:02:33 +02:00
5283491a3b
refactor: .gitignore file
This commit removes 'mariadb' and 'mongodb' from the .gitignore file and adds '.data'. These changes ensure that project-specific data and generated files are properly ignored by the version control system.
2024-05-15 11:02:05 +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
f5a9885589
feat: switch CONTEXT from prod to dev in .env.example
This commit adjusts the .env.exemple file to better suit development needs, by updating the CONTEXT variable from 'prod' to 'dev'. This change provides easier environment setup for local testing and development.

Signed-off-by: Mathis <mherriot@yidhra.fr>
2024-05-15 09:15:24 +02:00
Mathis
66d83db9a7 feat: Add SQL dialect file for MariaDB
This commit includes a new file, sqldialects.xml, which specifies the SQL dialect to be MariaDB for the databases service. This additional configuration complements and improves the interaction with MariaDB databases.
2024-05-14 23:42:11 +02:00
Mathis
b3e319a259 feat: Add users and follows tables in maria.sql
Added two new tables, 'users' and 'follows', to the maria.sql file. These tables are designed to store user information and follow relationships between users respectively.
2024-05-14 23:35:31 +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
9b9b635989
feat: update environment variables
Update .env.example file with production context details. Includes changes like modifying the CONTEXT from 'dev' to 'prod', adding MYSQL_HOST variable, and replacing MONGO_COLLECTION with MONGO_DATABASE.
2024-05-14 16:52:45 +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
f711dd5d49
feat: add new environment variables to .env.exemple
This commit introduces some additional environment variables to the .env.exemple file. The new variables include settings for the application port, debug mode, context, MySQL port, and MongoDB port.
2024-05-13 16:52:02 +02:00
71741924d0
refactor: use environment variables for ports in docker-compose
The docker-compose file has been updated to utilize environment variables for the MongoDB and MySQL ports. Instead of hard-coding the port numbers, the system now dynamically fetches port values from the .env file, which increases versatility and configurability.
2024-05-13 14:28:36 +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
91f431837f
feat: Add package.json for the application
This commit introduces a package.json file for the application. It includes scripts, dependencies, and devDependencies necessary for running and developing 'brief-06-back', a social networking platform. This ensures necessary packages are installed and scripts are easily accessible.
2024-05-13 10:54:10 +02:00
5dd4669c33
feat: add new tsconfig.json configuration file
This commit introduces a new tsconfig.json file to control TypeScript compiler options. The configuration includes settings for compiler options such as strict type checking, module resolution, and decorator metadata emission, as well as specifying base and output directory.
2024-05-13 10:52:50 +02:00
b3ca51f085
feat: Add new project configuration files
This commit introduces new configuration files for the project, which includes modifications in the .iml file, creation of data sources, and changes in misc, modules and VCS settings. These files help in streamlining IDE settings for the project, database connections, version control system preferences and other project-level settings.
2024-05-13 10:51:54 +02:00
c17ca369b3
feat: Ignore specific directories and files in Git
This commit updates .gitignore and adds .idea/.gitignore to ignore certain directories and files. The tracked files that are now ignored include IDE-specific files, third-party libraries, environment variables, and database files, providing cleaner and more focused commits.
2024-05-13 10:49:49 +02:00
6e16c296af
feat: add docker-compose.yml for database services
This commit introduces a new docker-compose.yml file to manage MariaDB and MongoDB services. It includes service environment configuration, necessary ports, and volume paths. The services are set to always restart.
2024-05-13 10:49:11 +02:00
f7b719dbba
feat: add .env.example file
A new file, .env.example, has been added. It contains configuration for both MySQL and MongoDB, including username, password, and database information.
2024-05-13 10:47:39 +02:00
407bc14082
feat: Add new biome configuration file
The commit introduces a new configuration file, biome.json, for managing imports, file inclusions, git features, linting rules, and formatting settings. This file defines settings for our project such as enabling organizing imports, specifying to include all TypeScript files in the src directory, enabling version control system using git, enabling linting with specific rules, and setting indents and line width for the formatter.
2024-05-13 09:39:45 +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
085a940dd1 Initial commit 2024-05-13 09:30:22 +02:00