doxa-maps-cdn/server/api/regions.get.ts
corsacca eae6143be1
Replace country pages with region dashboards (#23)
* replace country pages with region dashboards

- move /countries to /regions, with 301 redirects from the old URLs in
  every locale
- add a region dashboard: a map of the region's countries with pins
  coloured by prayer coverage, headline figures, and prayer, adoption and
  engagement progress against the DOXA goals, plus a per-country table
- roll up progress stats per country and region in the shared summary
  and serve them from /api/regions
- frame region maps with antimeridian-aware bounds
- add Regions to the hamburger menu and translate the new strings in all
  eight locales

* put each region on the regions index in a card with a header band

The region name links to its dashboard with the site's chevron icon, and
the people-group and country counts sit centred beside it on a brand-green
header; the country list is the padded white card body.
2026-09-07 11:49:24 +01:00

23 lines
1,011 B
TypeScript

/**
* GET /api/regions
* Returns one summary per WAGF region that has people groups: slug, localized
* label, progress stats (people groups, population, adopted, engaged, prayer
* coverage), a map center/zoom framed on the region, and its countries (each
* with the same stats). Supports translated labels via ?lang=.
*
* Powers the /regions index, each /regions/[region] dashboard and each
* /regions/[country] page.
*/
import { getRegionsSummary, resolveLang } from '../utils/countries'
export default defineEventHandler(async (event) => {
const lang = resolveLang(getQuery(event).lang)
const regions = await getRegionsSummary(lang)
// Shorter edge TTL than the marketing HTML so the dashboards' client-side
// refresh picks up progress within the hour; stale-while-revalidate keeps
// responses instant while the edge refreshes.
setResponseHeader(event, 'cache-control', 'public, max-age=0, s-maxage=3600, stale-while-revalidate=86400')
return { regions, total: regions.length }
})