Cleaning code for index.js

This commit is contained in:
Adolfo Reyna
2025-02-20 23:27:13 -05:00
parent e4dfee39ff
commit 0b20f05124
10 changed files with 364 additions and 414 deletions

View File

@@ -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);