Skip to content

Commit f83a836

Browse files
authored
Merge pull request #44 from SelfSend/15-implement-post-validate-for-single-email-validation Closes #15
15 implement post validate for single email validation Closes #15
2 parents a7f7088 + ec564be commit f83a836

23 files changed

Lines changed: 491 additions & 40 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
1-
name: Basic CI
1+
name: CI
22
on: [push, pull_request]
33

4-
env:
5-
CARGO_TERM_COLOR: always
6-
MONGODB_URI: ${{ secrets.MONGODB_URI }}
7-
DB_NAME: ${{ secrets.DB_NAME }}
8-
DB_DISPOSABLE_EMAILS_COLLECTION: ${{ secrets.DB_DISPOSABLE_EMAILS_COLLECTION }}
9-
104
jobs:
115
basic-checks:
126
runs-on: ubuntu-latest
137
env:
148
CARGO_TERM_COLOR: always
159
MONGODB_URI: ${{ secrets.MONGODB_URI }}
16-
DB_NAME: ${{ secrets.DB_NAME }}
10+
DB_NAME_TEST: ${{ secrets.DB_NAME_TEST }}
11+
DB_NAME_PRODUCTION: ${{ secrets.DB_NAME_PRODUCTION }}
1712
DB_DISPOSABLE_EMAILS_COLLECTION: ${{ secrets.DB_DISPOSABLE_EMAILS_COLLECTION }}
1813
steps:
1914
- name: Checkout code
@@ -29,7 +24,12 @@ jobs:
2924
run: cargo build --verbose
3025

3126
- name: Run Tests
32-
run: cargo test --verbose -- --skip test_disposable_email --skip test_non_disposable_email # test on local machine
27+
run: cargo test --verbose
28+
29+
- name: Upload coverage reports to Codecov
30+
uses: codecov/codecov-action@v5
31+
with:
32+
token: ${{ secrets.CODECOV_TOKEN }}
3333

3434
- name: Check Formatting
3535
run: cargo fmt --all -- --check

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
.DS_Store
1010
.idea/
1111
.vscode/
12+
notes

Cargo.lock

Lines changed: 20 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "email-sanitizer"
3-
version = "0.3.0+sprint1"
3+
version = "0.4.0+sprint2"
44
edition = "2024"
55

66
[dependencies]
@@ -12,6 +12,7 @@ chrono = "0.4.40"
1212
serde_json = "1.0.140"
1313
trust-dns-resolver = "0.23.2"
1414
mongodb = { version = "3.2.3" }
15+
futures = "0.3.31"
1516

1617
[dev-dependencies]
1718
husky = "0.3.0"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
GET http://localhost:8080/api/v1/health
2+
3+
// HTTP/1.1 200 OK
4+
// content-length: 65
5+
// connection: close
6+
// content-type: application/json
7+
// date: Wed, 16 Apr 2025 12:45:04 GMT
8+
9+
// {
10+
// "status": "UP",
11+
// "timestamp": "2025-04-16T12:45:04.133150700+00:00"
12+
// }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POST http://localhost:8080/api/v1/validate-email
2+
Content-Type: application/json
3+
4+
{ "email": "isdisposable@disposableemail.org" }
5+
6+
// HTTP/1.1 400 Bad Request
7+
// content-length: 81
8+
// connection: close
9+
// content-type: application/json
10+
// date: Wed, 16 Apr 2025 13:51:26 GMT
11+
12+
// {
13+
// "error": "DISPOSABLE_EMAIL",
14+
// "message": "The email address domain is a provider of disposable email addresses"
15+
// }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POST http://localhost:8080/api/v1/validate-email
2+
Content-Type: application/json
3+
4+
{ "email": "oksyntax@isnotdisposable.com" }
5+
6+
// HTTP/1.1 400 Bad Request
7+
// content-length: 76
8+
// connection: close
9+
// content-type: application/json
10+
// date: Wed, 16 Apr 2025 13:39:41 GMT
11+
12+
// {
13+
// "error": "INVALID_DOMAIN",
14+
// "message": "Email domain has no valid DNS records"
15+
// }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POST http://localhost:8080/api/v1/validate-email
2+
Content-Type: application/json
3+
4+
{ "email": "invalidsyntax" }
5+
6+
// HTTP/1.1 400 Bad Request
7+
// content-length: 71
8+
// connection: close
9+
// content-type: application/json
10+
// date: Wed, 16 Apr 2025 13:24:21 GMT
11+
12+
// {
13+
// "error": "INVALID_SYNTAX",
14+
// "message": "Email address has invalid syntax"
15+
// }
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POST http://localhost:8080/api/v1/validate-email
2+
Content-Type: application/json
3+
4+
{ "email": "user@example.com" }
5+
6+
// HTTP/1.1 200 OK
7+
// content-length: 53
8+
// connection: close
9+
// content-type: application/json
10+
// date: Wed, 16 Apr 2025 13:36:35 GMT
11+
12+
// {
13+
// "status": "VALID",
14+
// "message": "Email address is valid"
15+
// }

readme.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
[![Basic CI](https://github.com/SelfSend/email-sanitizer-api/actions/workflows/ci.yml/badge.svg)](https://github.com/SelfSend/email-sanitizer-api/actions/workflows/ci.yml)
1+
[![CI](https://github.com/SelfSend/email-sanitizer-api/actions/workflows/ci.yml/badge.svg)](https://github.com/SelfSend/email-sanitizer-api/actions/workflows/ci.yml)
2+
[![codecov](https://codecov.io/gh/SelfSend/email-sanitizer-api/branch/main/graph/badge.svg)](https://codecov.io/gh/SelfSend/email-sanitizer-api)
23

34
# email-sanitizer by SelfSend
45

@@ -53,7 +54,7 @@ Follows RFC specifications by checking A/AAAA records if MX records are missing.
5354

5455
### Disposable Email Address Validation Checks
5556

56-
Checks among a list of 106,543 disposable email domains, the largest database of disposable emails out there. The list is updated daily and includes domains from various disposable email providers.
57+
Checks among a list of 106,543 disposable email domains, the largest database of disposable emails out there, updated daily.
5758

5859
## 🛠 Tech Stack
5960

@@ -78,7 +79,7 @@ Checks among a list of 106,543 disposable email domains, the largest database of
7879

7980
1. Clone the repo:
8081
```bash
81-
git clone https://github.com/SelfSend/email-sanitizer.git
82+
git clone https://github.com/SelfSend/email-sanitizer-api.git
8283
```
8384
2. Install Dependencies:
8485
```bash
@@ -113,7 +114,8 @@ cargo build --release
113114
- Create a branch:
114115

115116
```bash
116-
git checkout -b feat/issue-number-issue-name #9-set-up-rust-project-with-actixaxum
117+
git checkout -b feat/issue-number-issue-name
118+
#git checkout -b "feat/9-set-up-rust-project-with-actixaxum"
117119
```
118120

119121
- Follow Conventional Commits.
@@ -131,26 +133,26 @@ MIT License.
131133

132134
###### **Tasks**
133135

134-
1. **Project Initialization**
136+
1. **Project Initialization**
135137

136-
- Set up Rust project with Actix/Axum.
137-
- Configure CI/CD (GitHub Actions).
138-
- **DoD**: Project builds successfully, CI pipeline passes.
138+
- Set up Rust project with Actix/Axum.
139+
- Configure CI/CD (GitHub Actions).
140+
- **DoD**: Project builds successfully, CI pipeline passes.
139141

140-
2. **Basic Email Validation**
142+
2. **Basic Email Validation**
141143

142-
- Implement syntax validation (regex).
143-
- Add DNS/MX record verification.
144-
- **DoD**: Unit tests cover 90% of cases, returns structured validation results.
144+
- Implement syntax validation (regex).
145+
- Add DNS/MX record verification.
146+
- **DoD**: Unit tests cover 90% of cases, returns structured validation results.
145147

146-
3. **MongoDB Integration & Disposable emails validation**
148+
3. **MongoDB Integration & Disposable emails validation**
147149

148-
- Design database schema for disposable email domains.
149-
- Implement disposable email addreses validation.
150-
- **DoD**: DB migrations applied, test queries succeed.
150+
- Design database schema for disposable email domains.
151+
- Implement disposable email addreses validation.
152+
- **DoD**: DB migrations applied, test queries succeed.
151153

152154
4. **REST API (Basic Endpoints)**
153-
- Implement `POST /validate` for single email validation.
155+
- Implement `POST /validate` for single email validation.
154156
- Add error handling and OpenAPI docs.
155157
- **DoD**: Endpoint tested via Postman, Swagger UI works.
156158

@@ -253,4 +255,4 @@ MIT License.
253255

254256
---
255257

256-
![selfsend-github-bio](https://github.com/user-attachments/assets/dbbabdc1-7e2b-4faf-93f9-03e3aa21a912)
258+
![selfsend-github-bio](https://github.com/user-attachments/assets/66e57877-06d3-4156-b5d6-cd4a28f30c71)

0 commit comments

Comments
 (0)