2022-10-20 01:52:47 -07:00
|
|
|
import cachedFetch from "utils/proxy/cached-fetch";
|
|
|
|
|
|
|
|
export default async function handler(req, res) {
|
2022-12-05 09:41:19 -08:00
|
|
|
const { latitude, longitude, units, cache, timezone } = req.query;
|
2022-10-20 01:52:47 -07:00
|
|
|
const degrees = units === "imperial" ? "fahrenheit" : "celsius";
|
2022-12-05 09:41:19 -08:00
|
|
|
const timezeone = timezone ?? 'auto'
|
|
|
|
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset¤t_weather=true&temperature_unit=${degrees}&timezone=${timezeone}`;
|
2022-10-20 01:52:47 -07:00
|
|
|
return res.send(await cachedFetch(apiUrl, cache));
|
|
|
|
}
|