import { fetch } from "https://esm.town/v/std/fetch";
export const simpleClimbing = (async () => {
const areas = [
{
name: "Holcomb",
id: 679,
mtnProjId: 105805238,
},
{
name: "Red Rock",
id: 560,
mtnProjId: 105731932,
},
{
name: "Joshua Tree",
id: 506,
mtnProjId: 105720495,
},
{
name: "Tahquitz",
id: 517,
mtnProjId: 105788020,
},
{
name: "Yosemite",
id: 518,
mtnProjId: 105833381,
},
{
name: "Woodson",
id: 718,
mtnProjId: 105791148,
},
{
name: "Culp",
id: 947,
mtnProjId: 106116317,
},
{
name: "Eagle Peak",
id: 1054,
mtnProjId: 107008184,
},
{
name: "El Cajon",
id: 750,
mtnProjId: 105793290,
},
{
name: "New Jack",
id: 677,
mtnProjId: 105865045,
},
{
name: "Mission Gorge",
id: 738,
mtnProjId: 105790250,
},
];
const rawWeatherData = await Promise.all(
areas.map(async (
a,
) => (await fetch(
`https://api.climbingweather.com/area/detail/${a.id}?days=1`,
).then((r) => r.json()).then((d) => ({
...d,
...a,
})))),
);
return rawWeatherData.map((w) => ({
id: w.areaId,
name: w.name,
hi: w.forecast.daily.data[0].temperatureHigh,
lo: w.forecast.daily.data[0].temperatureLow,
precipProb: parseFloat(w.forecast.daily.data[0].precipProbability),
windSpeed: w.forecast.daily.data[0].windSpeed,
windGust: w.forecast.daily.data[0].windGust,
mtnProjURL: `https://www.mountainproject.com/area/${w.mtnProjId}`,
color: w.color,
}));
})();