final fix for all api

This commit is contained in:
Ashwani Senapati
2025-11-29 18:10:02 +05:30
parent 8afb5012b2
commit 2fb1ea24b6
4 changed files with 19 additions and 6 deletions

View File

@@ -14,9 +14,10 @@ import mongoose from "mongoose";
// }
// };
const connectToAchievementsDB = async () => {
if (mongoose.connection.readyState >= 1) {
console.log("✅ Already connected to Achievements MongoDB");
return;
if (mongoose.connection.readyState >= 1) {
console.log("⚠️ Existing connection found. Closing it...");
await mongoose.connection.close();
console.log("✅ Previous connection closed");
}
try {

View File

@@ -1,7 +1,11 @@
import mongoose from "mongoose";
const connectToDatabase = async () => {
if (mongoose.connection.readyState >= 1) return;
if (mongoose.connection.readyState >= 1) {
console.log("⚠️ Existing connection found. Closing it...");
await mongoose.connection.close();
console.log("✅ Previous connection closed");
};
try {
await mongoose.connect(process.env.MongoURL, {

View File

@@ -2,7 +2,11 @@ import mongoose from "mongoose";
const connectToEventDB = async () => {
if (mongoose.connection.readyState >= 1) return;
if (mongoose.connection.readyState >= 1) {
console.log("⚠️ Existing connection found. Closing it...");
await mongoose.connection.close();
console.log("✅ Previous connection closed");
};
try {
await mongoose.connect(process.env.MongoURL!, {

View File

@@ -2,7 +2,11 @@ import mongoose from "mongoose";
const connectToTeamDB = async () => {
if (mongoose.connection.readyState >= 1) return;
if (mongoose.connection.readyState >= 1) {
console.log("⚠️ Existing connection found. Closing it...");
await mongoose.connection.close();
console.log("✅ Previous connection closed");
};
try {
await mongoose.connect(process.env.MongoURL!, {