Skip to content

Commit 0b8363c

Browse files
committed
Add /resend endpoint and simplify meta
Introduce a new /resend route (app/api/resend/resend.py) that returns a basic resend action and verifies RESEND_API_KEY from the environment. Export the router in app/api/resend/__init__.py and register it in app/api/routes.py; also add the resend entry to the root endpoints list in app/api/root.py. Simplify and reformat the metadata structure returned by make_meta (app/utils/make_meta.py) by removing redundant fields and normalizing keys (severity, message, base_url, version, time).
1 parent 064bf6e commit 0b8363c

5 files changed

Lines changed: 35 additions & 6 deletions

File tree

app/api/resend/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Resend Routes"""
2+
3+
from .resend import router as prospects_resend

app/api/resend/resend.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
from app import __version__
3+
import os
4+
from app.utils.make_meta import make_meta
5+
6+
from fastapi import APIRouter, Query, Path, Body, HTTPException
7+
8+
from app.utils.db import get_db_connection
9+
10+
11+
router = APIRouter()
12+
base_url = os.getenv("BASE_URL", "http://localhost:8000")
13+
14+
RESEND_API_KEY = os.getenv("RESEND_API_KEY")
15+
16+
@router.get("/resend")
17+
def root() -> dict:
18+
"""GET /resend endpoint."""
19+
if not RESEND_API_KEY:
20+
meta = make_meta("error", "RESEND_API_KEY is missing from environment. Please set it in your .env file.")
21+
return {"meta": meta}
22+
meta = make_meta("success", "Resend endpoint")
23+
data = [
24+
{"action,": f"send email"},
25+
]
26+
return {"meta": meta, "data": data}

app/api/root.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def root() -> dict:
2121
}
2222
endpoints = [
2323
{"name": "docs", "url": f"{base_url}/docs"},
24+
{"name": "resend", "url": f"{base_url}/resend"},
2425
{"name": "health", "url": f"{base_url}/health"},
2526
{"name": "prompts", "url": f"{base_url}/prompts"},
2627
{"name": "prospects", "url": f"{base_url}/prospects"},

app/api/routes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from app.api.root import router as root_router
1414
from app.api.health import router as health_router
15+
from app.api.resend.resend import router as resend_router
1516
from app.api.prompts.prompts import router as prompts_router
1617
from app.api.prospects.prospects import router as prospects_router
1718
from app.api.prospects.search import router as prospects_search_router
@@ -21,6 +22,7 @@
2122
from app.api.prospects.database.process import router as prospects_process_router
2223

2324
router.include_router(root_router)
25+
router.include_router(resend_router)
2426
router.include_router(health_router)
2527
router.include_router(prompts_router)
2628
router.include_router(prospects_search_router)

app/utils/make_meta.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@ def make_meta(severity: str, title: str) -> dict:
77
base_url = os.getenv("BASE_URL", "http://localhost:8000")
88
epoch = int(time.time() * 1000)
99
return {
10-
"severity": severity,
11-
"title": title,
1210
"version": __version__,
13-
"endpoint": f"{base_url}/prospects",
14-
"base": base_url,
15-
"base_url": base_url,
16-
"message": title,
1711
"time": epoch,
12+
"severity": severity,
13+
"message": title,
14+
"base_url": base_url,
1815
}

0 commit comments

Comments
 (0)