MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / loadDatabase

Function loadDatabase

packages/geo/src/geo.ts:21–36  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19let readerPromise: Promise<ReaderModel | null> | null = null;
20
21async function loadDatabase(): Promise<ReaderModel | null> {
22 try {
23 const dbBuffer = await readFile(dbPath);
24 console.log('GeoLite2-City.mmdb loaded (dist)', dbPath);
25 return Reader.openBuffer(dbBuffer);
26 } catch {
27 try {
28 const dbBuffer = await readFile(dbPathLocal);
29 console.log('GeoLite2-City.mmdb loaded (local)', dbPathLocal);
30 return Reader.openBuffer(dbBuffer);
31 } catch {
32 console.error('GeoLite2-City.mmdb not found', { dbPath, dbPathLocal });
33 return null;
34 }
35 }
36}
37
38function getReader(): Promise<ReaderModel | null> {
39 if (!readerPromise) {

Callers 1

getReaderFunction · 0.85

Calls 2

logMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected