Merge remote-tracking branch 'forkorigin/main' into features/basic-docker-swarm

This commit is contained in:
Vinay Dawani 2022-12-11 02:42:22 -05:00
commit f51e755216
167 changed files with 7060 additions and 969 deletions

View file

@ -69,7 +69,7 @@ export default async function handler(req, res) {
});
} catch {
res.status(500).send({
error: "unknown error",
error: {message: "Unknown error"},
});
}
}

View file

@ -35,6 +35,7 @@ export default async function handler(req, res) {
return res.status(200).json({
status: info.State.Status,
health: info.State.Health?.Status
});
}
@ -56,6 +57,7 @@ export default async function handler(req, res) {
return res.status(200).json({
status: info.State.Status,
health: info.State.Health?.Status
});
}

35
src/pages/api/ping.js Normal file
View file

@ -0,0 +1,35 @@
import { performance } from "perf_hooks";
import createLogger from "utils/logger";
import { httpProxy } from "utils/proxy/http";
const logger = createLogger("ping");
export default async function handler(req, res) {
const { ping: pingURL } = req.query;
if (!pingURL) {
logger.debug("No ping URL specified");
return res.status(400).send({
error: "No ping URL given",
});
}
let startTime = performance.now();
let [status] = await httpProxy(pingURL, {
method: "HEAD"
});
let endTime = performance.now();
if (status >= 400) {
// try one more time as a GET in case HEAD is rejected for whatever reason
startTime = performance.now();
[status] = await httpProxy(pingURL);
endTime = performance.now();
}
return res.status(200).json({
status,
latency: endTime - startTime
});
}

View file

@ -1,8 +1,9 @@
import cachedFetch from "utils/proxy/cached-fetch";
export default async function handler(req, res) {
const { latitude, longitude, units, cache } = req.query;
const { latitude, longitude, units, cache, timezone } = req.query;
const degrees = units === "imperial" ? "fahrenheit" : "celsius";
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset&current_weather=true&temperature_unit=${degrees}&timezone=auto`;
const timezeone = timezone ?? 'auto'
const apiUrl = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}&daily=sunrise,sunset&current_weather=true&temperature_unit=${degrees}&timezone=${timezeone}`;
return res.send(await cachedFetch(apiUrl, cache));
}