Skip to content

Commit f4e87ba

Browse files
Merge pull request #47 from goldlabelapps/staging
Refactor resend email util and simplify endpoint
2 parents d8ba8bd + e721ffd commit f4e87ba

3 files changed

Lines changed: 9 additions & 11 deletions

File tree

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
## ![Python](/app/static/repoicon.png) Python
22

3-
> Python with FastAPI using Postgres & tsvector.
3+
> With FastAPI using Postgres & tsvector.
4+
5+
Open Source, production ready Python FastAPI/Postgres app.
46

5-
Open Source, production ready Python FastAPI/Postgres app.
67
[GitHub](https://github.com/goldlabelapps/python) |
7-
[onrender](https://nx-ai.onrender.com) |
8+
[onr]Render](https://nx-ai.onrender.com) |
89
[by Goldlabel](https://goldlabel.pro)
910

1011
- **Python 3.11+**

app/api/resend/resend.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from app.utils.make_meta import make_meta
55
from fastapi import APIRouter, Query, Path, Body, HTTPException
66
from app.utils.db import get_db_connection
7-
from .utils.send_email import send_email_resend
7+
from app.utils.send_email import send_email_resend
88

99
router = APIRouter()
1010
base_url = os.getenv("BASE_URL", "http://localhost:8000")
@@ -18,10 +18,7 @@ def root() -> dict:
1818
meta = make_meta("error", "RESEND_API_KEY is missing from environment. Please set it in your .env file.")
1919
return {"meta": meta}
2020
meta = make_meta("success", "Resend endpoint")
21-
data = [
22-
{"action": "send email"},
23-
]
24-
return {"meta": meta, "data": data}
21+
return {"meta": meta}
2522

2623

2724
# POST endpoint to send email
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import httpx
33
import os
44

5+
RESEND_API_KEY = os.getenv("RESEND_API_KEY")
56
RESEND_API_URL = "https://api.resend.com/emails"
67

78
def send_email_resend(to: str, subject: str, html: str, sender: str) -> dict:
8-
resend_api_key = os.getenv("RESEND_API_KEY")
9-
if not resend_api_key:
9+
if not RESEND_API_KEY:
1010
return {"error": "Missing RESEND_API_KEY"}
1111
headers = {
12-
"Authorization": f"Bearer {resend_api_key}",
12+
"Authorization": f"Bearer {RESEND_API_KEY}",
1313
"Content-Type": "application/json"
1414
}
1515
payload = {

0 commit comments

Comments
 (0)