Build an API route that returns nearby mental health resources so users in crisis always know where to turn.
GET /api/resources?lat=X&lng=Y&type=crisis|therapy|support&radius=25
Data sources (in priority order):
therapy and support typescrisis_hotlines database table (always available offline) — for crisis typeResponse:
{
resources: Resource[], // sorted by distance ascending
source: 'live' | 'cached' | 'fallback',
fetchedAt: string
}
Caching:
resources:{lat_2dp}:{lng_2dp}:{type}Rate limit: 20 req/min per IP using the existing lib/rate-limit.ts utility.
Write unit tests covering: cache hit, SAMHSA live fetch, SAMHSA failure with fallback, missing lat/lng (400 error).
No contributions yet.