| 1 | /** |
| 2 | * While rendering is paused across g1t (billing's `platform_pause`, |
| 3 | * `renders`; docs/SPEND-GUARDRAILS.md), no card is drawn: a request that |
| 4 | * misses the edge cache gets the brand card the cache already has, or a |
| 5 | * redirect to g1t's static logo. Either is kept only a minute, so cards |
| 6 | * come back soon after rendering is resumed. |
| 7 | */ |
| 8 | |
| 9 | /** g1t's logo on dark, served by the site as a static file. */ |
| 10 | export const STATIC_CARD = "https://g1t.sh/brand/g1t-logo-on-dark.png"; |
| 11 | |
| 12 | const PAUSED_CACHE_CONTROL = "public, max-age=60"; |
| 13 | |
| 14 | /** What a cache miss is answered with while renders are paused. */ |
| 15 | export function pausedCard(brand: Response | undefined): Response { |
| 16 | if (brand) { |
| 17 | const response = new Response(brand.body, brand); |
| 18 | response.headers.set("cache-control", PAUSED_CACHE_CONTROL); |
| 19 | return response; |
| 20 | } |
| 21 | return new Response(null, { |
| 22 | status: 302, |
| 23 | headers: { location: STATIC_CARD, "cache-control": PAUSED_CACHE_CONTROL, "access-control-allow-origin": "*" }, |
| 24 | }); |
| 25 | } |