mirror of
https://github.com/hanzoai/dataroom.git
synced 2026-10-30 18:41:07 +00:00
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
import { Geo } from "../types";
|
|
|
|
export function getGeoData(headers: {
|
|
[key: string]: string | string[] | undefined;
|
|
}): Geo {
|
|
return {
|
|
city: Array.isArray(headers["x-vercel-ip-city"])
|
|
? headers["x-vercel-ip-city"][0]
|
|
: headers["x-vercel-ip-city"],
|
|
region: Array.isArray(headers["x-vercel-ip-region"])
|
|
? headers["x-vercel-ip-region"][0]
|
|
: headers["x-vercel-ip-region"],
|
|
country: Array.isArray(headers["x-vercel-ip-country"])
|
|
? headers["x-vercel-ip-country"][0]
|
|
: headers["x-vercel-ip-country"],
|
|
latitude: Array.isArray(headers["x-vercel-ip-latitude"])
|
|
? headers["x-vercel-ip-latitude"][0]
|
|
: headers["x-vercel-ip-latitude"],
|
|
longitude: Array.isArray(headers["x-vercel-ip-longitude"])
|
|
? headers["x-vercel-ip-longitude"][0]
|
|
: headers["x-vercel-ip-longitude"],
|
|
};
|
|
}
|
|
|
|
export const LOCALHOST_GEO_DATA = {
|
|
continent: "Europe",
|
|
city: "Munich",
|
|
region: "BY",
|
|
country: "DE",
|
|
latitude: "48.1371",
|
|
longitude: "11.5761",
|
|
};
|
|
|
|
export const LOCALHOST_IP = "127.0.0.1";
|