Home Manual Reference Source

src/geoservice/main.js

import Evee from 'evee';
import API from './API';

export default class GeoService extends Evee {
    constructor() {
        super();
        
        this.api = new API();
        this.cacheLookups = true;
        this._cachedLookups = {};
    }

    async lookupGeo(ip) {
        if (!ip) {
            ip = '';
        }

        if (this.cacheLookups && this._cachedLookups[ip]) {
            return this._cachedLookups[ip];
        }

        var result = await this.api.geoip(ip);
        if (this.cacheLookups) {
            this._cachedLookups[ip] = result;
        }
        return result;
    }




}