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.
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.
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".
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.
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>
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>
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
A new file, .env.example, has been added. It contains configuration for both MySQL and MongoDB, including username, password, and database information.
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.