This commit is contained in:
14
backend/src/db.js
Normal file
14
backend/src/db.js
Normal file
@@ -0,0 +1,14 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const connectDB = async () => {
|
||||
try {
|
||||
await mongoose.connect(process.env.DB_URI);
|
||||
|
||||
console.log("MongoDB connected");
|
||||
} catch (error) {
|
||||
console.error("MongoDB connection error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = connectDB;
|
||||
16
backend/src/index.js
Normal file
16
backend/src/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
const express = require("express");
|
||||
|
||||
require('dotenv').config();
|
||||
const app = express();
|
||||
const connectDB = require("./db");
|
||||
|
||||
// connect database
|
||||
connectDB();
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
res.send("Hello from Proxmox container!");
|
||||
});
|
||||
|
||||
app.listen(5000, () => {
|
||||
console.log("Server running on port 5000");
|
||||
});
|
||||
Reference in New Issue
Block a user