add wifilocation flags
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
import memoizee from "memoizee";
|
||||
interface WigleApiResonse {
|
||||
response?: WifiLocationResponse,
|
||||
status_code: number,
|
||||
}
|
||||
|
||||
interface WifiLocationResponse {
|
||||
success: boolean;
|
||||
@ -43,7 +46,7 @@ interface Result {
|
||||
|
||||
export const getLocationForWifi = async (
|
||||
mac: string
|
||||
): Promise<WifiLocationResponse | undefined> => {
|
||||
): Promise<WigleApiResonse | undefined> => {
|
||||
try {
|
||||
const url = `${process.env.WIGLE_BASE_URL!}${process.env
|
||||
.WIGLE_NETWORK_SEARCH!}?netid=${encodeURIComponent(mac)}`;
|
||||
@ -57,17 +60,12 @@ export const getLocationForWifi = async (
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
return await response.json();
|
||||
return { status_code: response.status, response: await response.json() };
|
||||
}
|
||||
console.log(response.status);
|
||||
return undefined;
|
||||
return { status_code: response.status };
|
||||
} catch (error) {
|
||||
console.error("Error during call of API wigle.net:", error);
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
|
||||
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