Develop a backend endpoint to handle requests for newsletter subscriptions. The endpoint will accept an email address, validate and sanitize it, and then handle both successful and failed validations appropriately. If the email passes validation, it will be stored in the database and a 'success' response will be sent to the client. If validation fails, an error message will be returned._
Acceptance Criteria
Accepts and validates User's email.
Persist the data to the database.
Return the appropriate response and status code
Requirements
[x] Implement API endpoint with data validation and sanitization
[x] Set up database integration and secure storage
Expected Outcome
The user input data should be successfully sent to the backend, or the user will receive an error message if unsuccessful
Description
Develop a backend endpoint to handle requests for newsletter subscriptions. The endpoint will accept an email address, validate and sanitize it, and then handle both successful and failed validations appropriately. If the email passes validation, it will be stored in the database and a 'success' response will be sent to the client. If validation fails, an error message will be returned._
Acceptance Criteria
Requirements
Expected Outcome
Endpoint
HTTP POST
/api/v1/newsletter
Requests:
headers:
content-type: application/json
Responses:
Successful response
Unsuccessful Response:
Validation Error Response::
Database design
schema
Table new_letters { id uuid [primary key] email varchar(70) created_at timestamp updated_at timestamp }
_
Testing
The systems should have unit tests covering: