feat: complete implementation of dynamic GlobeMap coordinates, TDD workflow, and UI/UX enhancements
This commit is contained in:
1 parent
8ba1d8f959
commit
764c87c3c8
75 files changed
+3666
-1153
No files matched your search
@@ -0,0 +1,27 @@
|
||||
const mongoose = require('mongoose');
|
||||
const path = require('path');
|
||||
require('dotenv').config({ path: path.join(__dirname, '../../.env.local') });
|
||||
|
||||
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/backone_dpi';
|
||||
|
||||
async function connectDB() {
|
||||
try {
|
||||
if (mongoose.connection.readyState >= 1) return;
|
||||
await mongoose.connect(MONGODB_URI, { serverSelectionTimeoutMS: 2000 });
|
||||
console.log('[MongoDB] Connected successfully');
|
||||
} catch (error) {
|
||||
console.error('[MongoDB] Connection failed, switching to In-Memory DB:', error.message);
|
||||
try {
|
||||
const { MongoMemoryServer } = require('mongodb-memory-server');
|
||||
const mongod = await MongoMemoryServer.create();
|
||||
const uri = mongod.getUri();
|
||||
await mongoose.connect(uri, {});
|
||||
console.log('[MongoDB] Connected successfully to Virtual Memory Database!');
|
||||
} catch (memErr) {
|
||||
console.error('[MongoDB] Memory DB failed:', memErr.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = connectDB;
|
||||
|
||||
Reference in new issue
Block a user