import memoizee from "memoizee"; interface WifiLocationResponse { success: boolean; totalResults: number; first: number; last: number; resultCount: number; results: Result[]; searchAfter: string; search_after: number; } interface Result { trilat: number; trilong: number; ssid: string; qos: number; transid: string; firsttime: string; lasttime: string; lastupdt: string; netid: string; name?: string; type: string; comment?: string; wep: string; bcninterval: number; freenet: string; dhcp: string; paynet: string; userfound: boolean; channel: number; rcois: string; encryption: string; country: string; region: string; road: string; city?: string; housenumber?: string; postalcode: string; } export const getLocationForWifi = async ( mac: string ): Promise => { try { const url = `${process.env.WIGLE_BASE_URL!}${process.env .WIGLE_NETWORK_SEARCH!}?netid=${encodeURIComponent(mac)}`; const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", 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", });