adding more stuff and having more production

This commit is contained in:
talksik
2022-06-08 06:03:07 -05:00
parent 82db26e994
commit 9bf2507cdc
12 changed files with 245 additions and 96 deletions
+7 -10
View File
@@ -1,7 +1,7 @@
// External Dependencies
import * as mongoDB from "mongodb";
import * as mongoDB from 'mongodb';
import { loadConfig } from "../config";
import environmentVariables from '../config/config';
// Global Variables
export const collections: {
@@ -11,24 +11,21 @@ export const collections: {
} = {};
// Initialize Connection
const config = loadConfig();
export const client: mongoDB.MongoClient = new mongoDB.MongoClient(
config.MONGO_CONNECTION_STRING
environmentVariables.MONGO_CONNECTION_STRING,
);
client.connect();
const db: mongoDB.Db = client.db(process.env.DB_NAME);
const usersCollection: mongoDB.Collection = db.collection("users");
const lineCollection: mongoDB.Collection = db.collection("lines");
const lineMembersCollection: mongoDB.Collection = db.collection("lineMembers");
const usersCollection: mongoDB.Collection = db.collection('users');
const lineCollection: mongoDB.Collection = db.collection('lines');
const lineMembersCollection: mongoDB.Collection = db.collection('lineMembers');
collections.users = usersCollection;
collections.lines = lineCollection;
collections.lineMembers = lineMembersCollection;
console.log(
`Successfully connected to database: ${db.databaseName} and collections`
);
console.log(`Successfully connected to database: ${db.databaseName} and collections`);