Skip to content

Commit

Permalink
feat: move isHosting to the location object
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Dec 5, 2023
1 parent 2bd1351 commit 2879a12
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/geoip/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class GeoipClient {
this.lookupWithCache<LocationInfo>(`geoip:fastly:${addr}`, async () => fastlyLookup(addr)),
])
.then(([ ipinfo, ip2location, maxmind, ipmap, fastly ]) => {
isHosting = ip2location.status === 'fulfilled' ? ip2location.value.isHosting : null;
isHosting = ip2location.status === 'fulfilled' ? ip2location.value.location.isHosting : null;
const fulfilled: (LocationInfoWithProvider | null)[] = [];

// Providers here are pushed in a desc prioritized order
Expand Down
4 changes: 1 addition & 3 deletions src/lib/geoip/providers/ip2location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Ip2LocationResponse = {

export type Ip2LocationBundledResponse = {
location: LocationInfo,
isHosting: boolean | undefined,
isProxy: boolean,
};

Expand Down Expand Up @@ -61,12 +60,11 @@ export const ip2LocationLookup = async (addr: string): Promise<Ip2LocationBundle
longitude: result.longitude ?? 0,
network: result.as ?? '',
normalizedNetwork: normalizeNetworkName(result.as ?? ''),
isHosting: null,
isHosting: result.usage_type ? HOSTING_USAGE_TYPES.includes(result.usage_type) : null,
};

return {
location,
isHosting: result.usage_type ? HOSTING_USAGE_TYPES.includes(result.usage_type) : undefined,
isProxy: result.is_proxy ?? false,
};
};

0 comments on commit 2879a12

Please sign in to comment.