20260607 - login, add scene, add hotspot

This commit is contained in:
2026-06-07 21:31:31 +07:00
parent 10d2e07297
commit 5ba6e37039
29 changed files with 1064 additions and 73 deletions
+12 -1
View File
@@ -1,8 +1,19 @@
const mongoose = require('mongoose');
const path = require('path');
const dotenv = require('dotenv');
// Tự động tìm và nạp file .env nằm cùng thư mục với folder config (tức là trong backend/.env)
dotenv.config({ path: path.join(__dirname, '../.env') });
const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGODB_URI);
const dbURI = process.env.MONGODB_URI;
if (!dbURI) {
throw new Error('MONGODB_URI is not defined in .env file');
}
const conn = await mongoose.connect(dbURI);
console.log(`MongoDB Connected: ${conn.connection.host}`);
} catch (error) {
console.error(`Error connecting to MongoDB: ${error.message}`);