Development
API Routes
Server API endpoints for client-side data fetching.
API Routes
All API routes live in app/api/ and require the x-tenant-id header set by proxy.js.
Endpoints
| Route | Method | Returns |
|---|---|---|
/api/category/[slug] | GET | Category JSON with KV-encoded ad config |
/api/article/[slug] | GET | Article JSON with KV-encoded ad config |
/api/questionnaire?slug= | GET | Questionnaire questions (fallback to default) |
/api/whatsapp?categorySlug= | GET | WhatsApp theme steps and config |
Request flow
Static routes
| Route | Purpose |
|---|---|
/ads.txt | Per-tenant ads.txt content |
/sw.js | Service worker (PushAlert + Taboola) |
Services layer
API routes delegate to lib/services/:
| Service | Model |
|---|---|
tenant.js | Tenant |
category.js | Category |
article.js | Article |
questionnaire.js | Questionnaire |
whatsapp-theme.js | WhatsAppTheme |
articleHome.js | ArticleHome |
All services encode KV values via lib/utils/kvEncoding.js before returning.