2019-12-16 13:02:51 +00:00
|
|
|
import SafeMongo from "@hibas123/safe_mongo";
|
2020-06-09 12:20:38 +00:00
|
|
|
import Config from "./config";
|
|
|
|
|
|
|
|
let dbname = "openauth";
|
|
|
|
let host = "localhost";
|
|
|
|
|
2019-12-16 13:02:51 +00:00
|
|
|
if (Config.database) {
|
|
|
|
if (Config.database.database) dbname = Config.database.database;
|
|
|
|
if (Config.database.host) host = Config.database.host;
|
|
|
|
}
|
2020-06-09 12:20:38 +00:00
|
|
|
|
2019-12-16 13:02:51 +00:00
|
|
|
if (Config.core.dev) dbname += "_dev";
|
2020-06-09 12:20:38 +00:00
|
|
|
|
|
|
|
const DB = new SafeMongo("mongodb://" + host, dbname, {
|
|
|
|
useUnifiedTopology: true,
|
|
|
|
useNewUrlParser: true,
|
|
|
|
} as any);
|
|
|
|
|
|
|
|
export default DB;
|