mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 23:08:48 +00:00
Feature: allow disable ipv6 in proxy, refactor cacheFetch to use proxy (#5011)
This commit is contained in:
parent
934ad3a6f1
commit
b4dc53c7c0
10 changed files with 61 additions and 65 deletions
|
@ -1,4 +1,4 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
import createLogger from "utils/logger";
|
||||
|
||||
const logger = createLogger("releases");
|
||||
|
@ -6,7 +6,7 @@ const logger = createLogger("releases");
|
|||
export default async function handler(req, res) {
|
||||
const releasesURL = "https://api.github.com/repos/gethomepage/homepage/releases";
|
||||
try {
|
||||
return res.send(await cachedFetch(releasesURL, 5));
|
||||
return res.send(await cachedRequest(releasesURL, 5));
|
||||
} catch (e) {
|
||||
logger.error(`Error checking GitHub releases: ${e}`);
|
||||
return res.send([]);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { searchProviders } from "components/widgets/search/search";
|
||||
|
||||
import { getSettings } from "utils/config/config";
|
||||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
import { widgetsFromConfig } from "utils/config/widget-helpers";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
|
@ -29,5 +29,5 @@ export default async function handler(req, res) {
|
|||
return res.json([query, []]); // Responde with the same array format but with no suggestions.
|
||||
}
|
||||
|
||||
return res.send(await cachedFetch(`${provider.suggestionUrl}${encodeURIComponent(query)}`, 5, "Mozilla/5.0"));
|
||||
return res.send(await cachedRequest(`${provider.suggestionUrl}${encodeURIComponent(query)}`, 5, "Mozilla/5.0"));
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { latitude, longitude, units, cache, timezone } = req.query;
|
||||
const degrees = units === "metric" ? "celsius" : "fahrenheit";
|
||||
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));
|
||||
return res.send(await cachedRequest(apiUrl, cache));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
import { getSettings } from "utils/config/config";
|
||||
import { getPrivateWidgetOptions } from "utils/config/widget-helpers";
|
||||
|
||||
|
@ -26,5 +26,5 @@ export default async function handler(req, res) {
|
|||
|
||||
const apiUrl = `https://api.openweathermap.org/data/2.5/weather?lat=${latitude}&lon=${longitude}&appid=${apiKey}&units=${units}&lang=${lang}`;
|
||||
|
||||
return res.send(await cachedFetch(apiUrl, cache));
|
||||
return res.send(await cachedRequest(apiUrl, cache));
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
import { getSettings } from "utils/config/config";
|
||||
import createLogger from "utils/logger";
|
||||
|
||||
|
@ -60,7 +60,7 @@ export default async function handler(req, res) {
|
|||
const apiUrl = `https://finnhub.io/api/v1/quote?symbol=${ticker}&token=${apiKey}`;
|
||||
// Finnhub free accounts allow up to 60 calls/minute
|
||||
// https://finnhub.io/pricing
|
||||
const { c, dp } = await cachedFetch(apiUrl, cache || 1);
|
||||
const { c, dp } = await cachedRequest(apiUrl, cache || 1);
|
||||
logger.debug("Finnhub API response for %s: %o", ticker, { c, dp });
|
||||
|
||||
// API sometimes returns 200, but values returned are `null`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import cachedFetch from "utils/proxy/cached-fetch";
|
||||
import { cachedRequest } from "utils/proxy/http";
|
||||
import { getSettings } from "utils/config/config";
|
||||
import { getPrivateWidgetOptions } from "utils/config/widget-helpers";
|
||||
|
||||
|
@ -26,5 +26,5 @@ export default async function handler(req, res) {
|
|||
|
||||
const apiUrl = `http://api.weatherapi.com/v1/current.json?q=${latitude},${longitude}&key=${apiKey}&lang=${lang}`;
|
||||
|
||||
return res.send(await cachedFetch(apiUrl, cache));
|
||||
return res.send(await cachedRequest(apiUrl, cache));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue