Skip to content

Commit e721ffd

Browse files
committed
Refactor resend email util and simplify endpoint
Move resend email helper from app/api/resend/utils to app/utils, use a module-level RESEND_API_KEY env var, and update the Authorization header to use it. Update import in resend endpoint to the new path and simplify the root response to only return meta. Also apply minor README wording and link fixes.
1 parent d12edff commit e721ffd

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)