feat: added cache version for api call
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import memoizee from "memoizee";
|
||||
|
||||
interface WifiLocationResponse {
|
||||
success: boolean;
|
||||
totalResults: number;
|
||||
@ -43,7 +45,6 @@ export const getLocationForWifi = async (
|
||||
mac: string
|
||||
): Promise<WifiLocationResponse | undefined> => {
|
||||
try {
|
||||
console.log(process.env.WIGLE_BASE_URL);
|
||||
const url = `${process.env.WIGLE_BASE_URL!}${process.env
|
||||
.WIGLE_NETWORK_SEARCH!}?netid=${encodeURIComponent(mac)}`;
|
||||
const response = await fetch(url, {
|
||||
@ -53,9 +54,14 @@ export const getLocationForWifi = async (
|
||||
Cookie: `auth=${process.env.WIGLE_TOKEN}`,
|
||||
},
|
||||
});
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
console.error("Fehler beim Aufruf des Services:", error);
|
||||
}
|
||||
};
|
||||
|
||||
export const getLocationForWifiMemoized = memoizee(getLocationForWifi, {
|
||||
maxAge: Number(process.env.GET_LOCATION_WIFI_MAX_AGE),
|
||||
max: Number(process.env.GET_LOCATION_WIFI_MAX),
|
||||
primitive: process.env.GET_LOCATION_WIFI_PRIMITIVE === "true",
|
||||
});
|
||||
|
Reference in New Issue
Block a user