import { env } from "fastly:env";
function handler(event) {
var now = new Date();
let respBody = JSON.stringify({
fastly_pop: env("FASTLY_POP") ? env("FASTLY_POP") : "TYO",
origin0: (Backend.health('origin_0') == 'healthy') ? true : false,
origin1: (Backend.health('origin_1') == 'healthy') ? true : false,
originUnhealthy: (Backend.health('F_origin_unhealthy') == 'healthy') ? true : false,
timestamp: now,
})
return new Response(respBody, {
statsus: 200,
headers: {
"Content-Type": "application/json",
},
})
}
addEventListener("fetch", (event) => event.respondWith(handler(event)))