mirror of https://github.com/wg-easy/wg-easy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
505 B
24 lines
505 B
/**
|
|
* 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((db) => {
|
|
provider = db;
|
|
WireGuard.Startup();
|
|
});
|
|
|
|
export default provider;
|
|
|