mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-05-13 10:36:21 +02:00
oref-alerts: s-maxage 180s → 300s (5 min), stale-while-revalidate 60s → 120s youtube/live: channel-based s-maxage 300s → 600s (10 min) for both relay and direct scrape paths
27 lines
802 B
JavaScript
27 lines
802 B
JavaScript
import { createRelayHandler } from './_relay.js';
|
|
|
|
export const config = { runtime: 'edge' };
|
|
|
|
export default createRelayHandler({
|
|
buildRelayPath: (_req, url) => {
|
|
const endpoint = url.searchParams.get('endpoint');
|
|
return endpoint === 'history' ? '/oref/history' : '/oref/alerts';
|
|
},
|
|
forwardSearch: false,
|
|
timeout: 12000,
|
|
onlyOk: true,
|
|
cacheHeaders: () => ({
|
|
'Cache-Control': 'public, max-age=60, s-maxage=300, stale-while-revalidate=120, stale-if-error=900',
|
|
}),
|
|
fallback: (_req, corsHeaders) => new Response(JSON.stringify({
|
|
configured: false,
|
|
alerts: [],
|
|
historyCount24h: 0,
|
|
timestamp: new Date().toISOString(),
|
|
error: 'No data source available',
|
|
}), {
|
|
status: 503,
|
|
headers: { 'Content-Type': 'application/json', ...corsHeaders },
|
|
}),
|
|
});
|