23 lines
583 B
TypeScript
23 lines
583 B
TypeScript
import SafeMongo from "@hibas123/safe_mongo";
|
|
import Config from "./config";
|
|
let dbname = "openauth";
|
|
let host = "localhost";
|
|
if (Config.database) {
|
|
if (Config.database.database) dbname = Config.database.database;
|
|
if (Config.database.host) host = Config.database.host;
|
|
}
|
|
if (Config.core.dev) dbname += "_dev";
|
|
|
|
let auth = undefined;
|
|
if (Config.database.username) {
|
|
auth = {
|
|
username: Config.database.username,
|
|
password: Config.database.password
|
|
}
|
|
}
|
|
|
|
const DB = new SafeMongo("mongodb://" + host, dbname, {
|
|
auth
|
|
});
|
|
export default DB;
|