re-storing

This commit is contained in:
MuhammadKhalilzadeh committed 2024-05-18 09:45:03 +03:30
1 parent b2c8e50043
commit f42492d07f
6 files changed
+27 -317

No files matched your search

+12 -31
View File
@@ -7,29 +7,20 @@ const { connectDbAndRunServer } = require("./configs/db");
require("dotenv").config();
const logger = require("./utils/logger");
// const { sendEmail } = require('./utils/sendEmail')
const pingSerivce = require("./service/pingService");
/**
* DB Notes
* Here is where we can swap out DBs easily. Spin up a mongoDB instance and try it out.
* Simply comment out the FakeDB and uncomment the MongoDB or vice versa.
* We can easily swap between any type of data source as long as the methods are implemented
*
* FakeDB
* const db = require("./db/FakeDb");
*
* MongoDB
* const db = require("./db/MongoDB");
*/
// **************************
// Here is where we can swap out DBs easily. Spin up a mongoDB instance and try it out.
// Simply comment out the FakeDB and uncomment the MongoDB or vice versa.
// We can easily swap between any type of data source as long as the methods are implemented
//
// FakeDB
// const db = require("./db/FakeDb");
//
// MongoDB
const db = require("./db/MongoDB");
//
// **************************
const DB_TYPE = {
MongoDB: () => require("./db/MongoDB"),
FakedDB: () => require("./db/FakeDb"),
};
const db = DB_TYPE[process.env.DB_TYPE]
? DB_TYPE[process.env.DB_TYPE]()
: require("./db/FakeDb");
/**
* NOTES
* Email Service will be added
@@ -79,13 +70,3 @@ app.use("/api/v1/healthy", (req, res) => {
});
connectDbAndRunServer(app, db);
pingSerivce.startPingService(db);
// Cleanup
const cleanup = async () => {
await pingSerivce.cleanup();
process.exit(0);
};
process.on("SIGINT", cleanup);
process.on("SIGTERM", cleanup);