Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT]: NewsLetter Page Api Endpoint - BACKEND #46

Open
6 tasks
Solomonuche opened this issue Jul 18, 2024 · 1 comment
Open
6 tasks

[FEAT]: NewsLetter Page Api Endpoint - BACKEND #46

Solomonuche opened this issue Jul 18, 2024 · 1 comment
Assignees
Labels

Comments

@Solomonuche
Copy link
Contributor

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

  • Accepts and validates User's email.
  • Persist the data to the database.
  • Return the appropriate response and status code

Requirements

  • Implement API endpoint with data validation and sanitization
  • Set up database integration and secure storage
  • Integrate email service for confirmation messages

Expected Outcome

  • The user input data should be successfully sent to the backend, or the user will receive an error message if unsuccessful

Status code

  • 201: Email was successfully stored.
  • 400: Invalid email address.
  • 401: Email already exist.
  • 500: A server error occurred.

Endpoint

[POST] /api/v1/pages/newsletter

Requests:

headers:

  • content-type: application/json
{
    "email": "string"
}

Responses:

Successful response

{
    "message": "string",
    "success": true,
    "status_code": int
}

Error response

{
    "message": "string",
    "success": false,
    "status_code": int
}

Database design

schema

Table name: subscribers_table

id:

  • constraints: string(uuid), unique, primary-key, not null

email:

  • constraints: string, unique, not null, length(150)

createdAt:

  • constraints: string, date timestamp

Testing

  1. Unit Tests

The systems should have unit tests covering:

  • Validates User's email and check for duplicate emails.
  • Ensure data is saved correctly to the database.
  • Test that the appropriate response and status code is returned
@Solomonuche
Copy link
Contributor Author

This Issue Links To The Approved Issue Here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Implementation
Development

No branches or pull requests

1 participant