2021-08-13 03:28:09 +00:00
|
|
|
// wrapper for the database drivers in ./database/
|
2022-02-22 00:55:25 +00:00
|
|
|
import { config } from "dotenv";
|
|
|
|
config();
|
2020-12-18 02:32:19 +00:00
|
|
|
|
2022-12-12 17:15:10 +00:00
|
|
|
let db = null;
|
|
|
|
|
|
|
|
if (process.env.DB) {
|
|
|
|
const dbtype = process.env.DB.split("://")[0];
|
|
|
|
try {
|
|
|
|
db = await import(`./database/${dbtype}.js`);
|
|
|
|
} catch (error) {
|
|
|
|
if (error.code == "ERR_MODULE_NOT_FOUND") {
|
|
|
|
console.error(`DB config option has unknown database type '${dbtype}'`);
|
|
|
|
process.exit(1);
|
|
|
|
}
|
|
|
|
throw error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default db;
|