mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-10 23:38:46 +00:00
Merge remote-tracking branch 'forkorigin/main' into features/basic-docker-swarm
This commit is contained in:
commit
f51e755216
167 changed files with 7060 additions and 969 deletions
|
@ -69,7 +69,7 @@ export default async function handler(req, res) {
|
|||
});
|
||||
} catch {
|
||||
res.status(500).send({
|
||||
error: "unknown error",
|
||||
error: {message: "Unknown error"},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
35
src/pages/api/ping.js
Normal 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
|
||||
});
|
||||
}
|
|
@ -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¤t_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¤t_weather=true&temperature_unit=${degrees}&timezone=${timezeone}`;
|
||||
return res.send(await cachedFetch(apiUrl, cache));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue