final fix for all api
This commit is contained in:
@@ -15,8 +15,9 @@ import mongoose from "mongoose";
|
|||||||
// };
|
// };
|
||||||
const connectToAchievementsDB = async () => {
|
const connectToAchievementsDB = async () => {
|
||||||
if (mongoose.connection.readyState >= 1) {
|
if (mongoose.connection.readyState >= 1) {
|
||||||
console.log("✅ Already connected to Achievements MongoDB");
|
console.log("⚠️ Existing connection found. Closing it...");
|
||||||
return;
|
await mongoose.connection.close();
|
||||||
|
console.log("✅ Previous connection closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
|
|
||||||
const connectToDatabase = async () => {
|
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 {
|
try {
|
||||||
await mongoose.connect(process.env.MongoURL, {
|
await mongoose.connect(process.env.MongoURL, {
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import mongoose from "mongoose";
|
|||||||
|
|
||||||
const connectToEventDB = async () => {
|
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 {
|
try {
|
||||||
await mongoose.connect(process.env.MongoURL!, {
|
await mongoose.connect(process.env.MongoURL!, {
|
||||||
|
|||||||
@@ -2,7 +2,11 @@ import mongoose from "mongoose";
|
|||||||
|
|
||||||
const connectToTeamDB = async () => {
|
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 {
|
try {
|
||||||
await mongoose.connect(process.env.MongoURL!, {
|
await mongoose.connect(process.env.MongoURL!, {
|
||||||
|
|||||||
Reference in New Issue
Block a user