Simple API gateway for webhooks

feat: include country flag emoji

finxol.io 876f8692 e3adea51

verified
Changed files
+15
src
+15
src/sensors.ts
···
return c.text("Invalid country data", 400)
}
+
const letterA = "a".codePointAt(0) as number
+
//biome-ignore format: breaks emoji
+
const regionalIndicatorA = "🇦".codePointAt(0) as number
+
+
const toRegionalIndicator = (char: string) =>
+
String.fromCodePoint(
+
char.codePointAt(0) as number - letterA + regionalIndicatorA,
+
)
+
+
const emoji = country.data.features[0].properties.country_code
+
.split("")
+
.map((char) => toRegionalIndicator(char))
+
.join("")
+
const ret = {
country: country.data.features[0].properties.country,
country_code: country.data.features[0].properties.country_code,
+
country_flag: emoji,
}
// Cache country data to KV store (expiry set for 2 hours)