Task Description: Implement a User Registration Feature
Implement the user registration functionality in the application. The feature should allow new users to create an account by providing their username, email, and password. The following specific requirements must be met for the test cases to pass:
User Registration Endpoint:
Create a RESTful API endpoint at /api/register.
This endpoint should accept a POST request with a JSON body containing the fields username, email, and password.
Validation:
Ensure that the username is at least 3 characters long.
Ensure that the email is in a valid email format.
Ensure that the password is at least 8 characters long and contains at least one number and one special character.
User Existence Check:
Check if the username or email is already registered. If either exists, return a 409 Conflict status with an appropriate error message.
Password Hashing:
Use a secure hashing algorithm to hash the user's password before storing it in the database.
Database Interaction:
Integrate with the existing database schema to store the user information, ensuring the hashed password is saved alongside the username and email.
Success Response:
On successful registration, return a 201 Created status with a JSON response containing a success message and the newly created user's username and email.
Ensure that your implementation is placed in the /app/ directory. Once implemented, all provided test cases should pass, confirming the correctness of your solution.