Ground-Zerro / Phobos Public
Code Issues Pull requests Actions Releases View on GitHub ↗
580 B typescript
/**
 * Changing the Database Provider
 * This design allows for easy swapping of different database implementations.
 */
import { connect, type DBServiceType } from '#db/sqlite';

const nullObject = new Proxy(
  {},
  {
    get() {
      throw new Error('Database not yet initialized');
    },
  }
);

// eslint-disable-next-line import/no-mutable-exports
let provider = nullObject as never as DBServiceType;

connect().then(async (db) => {
  provider = db;
  await WireGuard.Startup();
  await Obfuscator.Startup();
  await WarpInterface.Startup();
});

export default provider;