import { readFileSync } from "fs";
import { dirname, resolve } from "path";
import { fileURLToPath } from "url";
import { Reader, ReaderModel } from "@maxmind/geoip2-node";
export class GeoLite2 {
    _reader;
    database;
    constructor(database) {
        this.database = database;
        this._reader = null;
    }
    get reader() {
        if (!this._reader) {
            const __dirname = dirname(fileURLToPath(import.meta.url));
            const dbPath = resolve(__dirname, `../database/GeoLite2-${this.database}.mmdb`);
            const dbBuffer = readFileSync(dbPath);
            this._reader = Reader.openBuffer(dbBuffer);
        }
        return this._reader;
    }
}
//# sourceMappingURL=index.js.map