Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/db/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ let db: mongoose.Connection;
const ConnectToDB = async () => {
const DatabaseUrl = process.env.LEADLLY_DB_URL as string;

try {
await mongoose.connect(DatabaseUrl);
db = mongoose.connection;
console.log("LEADLLY_DB_URL Connected.");
} catch (error) {
console.log(error);
}
try {
await mongoose.connect(DatabaseUrl);
db = mongoose.connection;
console.log("LEADLLY_DB_URL Connected.");
} catch (error) {
console.error("Database connection error:", error);
process.exit(1); // Exit the application on database connection failure
}
};

export {db};
Expand Down