mrmBot-Matrix/utils/database.js
2023-03-15 10:09:09 -04:00

20 lines
479 B
JavaScript

// wrapper for the database drivers in ./database/
import { config } from "dotenv";
config();
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;