Cleaning code for index.js
This commit is contained in:
@@ -3,22 +3,24 @@ const MongoClient = mongo.MongoClient;
|
||||
const ObjectID = mongo.ObjectID;
|
||||
const DBName = "EMI_SOCIAL";
|
||||
const mongoUrl = process.env.MONGO_URL;
|
||||
|
||||
// Extand DB with custom functions
|
||||
const postDB = require("./dbTools/post.js");
|
||||
const profileDB = require("./dbTools/profile.js");
|
||||
const paymentDB = require("./dbTools/payments.js");
|
||||
const loggerDB = require("./dbTools/logger.js");
|
||||
const songsDB = require("./dbTools/songs.js");
|
||||
|
||||
|
||||
console.log("Connecting to MongoDB...");
|
||||
|
||||
const getDB = new Promise((resolve, reject) => {
|
||||
const DB = {ObjectID: mongo.ObjectID};
|
||||
MongoClient.connect(mongoUrl, function(err, db) {
|
||||
if (err) return reject(err);
|
||||
|
||||
console.log("Connected to DB!");
|
||||
DB.db = db;
|
||||
DB.ObjectID = ObjectID;
|
||||
console.log("Connected to DB!");
|
||||
|
||||
DB.usersCol = db.db(DBName).collection("users");
|
||||
DB.tokensCol = db.db(DBName).collection("tokens");
|
||||
DB.invitationCol = db.db(DBName).collection("invitation");
|
||||
@@ -118,7 +120,6 @@ const getDB = new Promise((resolve, reject) => {
|
||||
postDB(DB);
|
||||
profileDB(DB);
|
||||
paymentDB(DB);
|
||||
loggerDB(DB);
|
||||
songsDB(DB);
|
||||
|
||||
resolve(DB);
|
||||
|
||||
Reference in New Issue
Block a user