feat: enhance GeoIP service to include ASN information in detailed responses

This commit is contained in:
Tudor Stanciu 2025-10-08 00:34:24 +03:00
parent 50320f8591
commit 27b3073907
2 changed files with 11 additions and 0 deletions

View File

@ -111,9 +111,12 @@ class GeoIPService {
try {
const response: City = this.cityReader!.city(ip);
const asnResponse: Asn = this.asnReader!.asn(ip);
const result: DetailedGeoIPResponse = {
ip,
location: response as GeoIPLocation,
asn: asnResponse,
};
this.cache.set(cacheKey, result);

View File

@ -37,6 +37,13 @@ export interface GeoIPLocation {
};
}
export interface AsnInfo {
autonomousSystemNumber?: number;
autonomousSystemOrganization?: string;
ipAddress?: string;
network?: string;
}
export interface SimplifiedGeoIPResponse {
ip: string;
country: string;
@ -58,6 +65,7 @@ export interface SimplifiedGeoIPResponse {
export interface DetailedGeoIPResponse {
ip: string;
location: GeoIPLocation;
asn: AsnInfo;
}
export interface BatchGeoIPRequest {