ping = deploy(
`ping`,
async (req, res, ctx) => {
async function ping(region) {
const coldTime = readableTimestamp();
const datapointCold = await timedRequest(region);
await baseRef.child(coldTime + region).set({
tag: "cold",
region,
time: coldTime,
...datapointCold
});
const warmTime = readableTimestamp();
const datapointWarm = await timedRequest(region);
await baseRef.child(warmTime + region).set({
tag: "warm",
region,
time: warmTime,
...datapointWarm
});
}
try {
const token = await getAccessTokenFromServiceAccount(
ctx.secrets["tomlarkworthy_webadmin_service_account_key"]
);
await signinWithAccessToken(firebase, token);
await Promise.all(regions.map(ping));
res.json("OK");
} catch (err) {
return res.json(err.message);
}
},
{
region: "europe-west1",
secrets: ["tomlarkworthy_webadmin_service_account_key"]
}
)