First commit

This commit is contained in:
2026-04-20 17:39:53 +02:00
commit 9f2578f7d2
28 changed files with 11986 additions and 0 deletions

3
backend/.env.production Normal file
View File

@@ -0,0 +1,3 @@
PORT=5000
DB_URI=mongodb://10.1.1.7:27017/
NODE_ENV=production

16
backend/.gitignore vendored Normal file
View File

@@ -0,0 +1,16 @@
# Node dependencies
node_modules
# Logs
logs
*.log
# Misc
.DS_Store
.fleet
.idea
# Local env files
.env
.env.*
!.env.production

23
backend/Dockerfile Normal file
View File

@@ -0,0 +1,23 @@
# Use official Node.js runtime
FROM node:20-alpine
# Create app directory
WORKDIR /usr/src/app
# Copy package files first (better caching)
COPY package*.json ./
# Install dependencies
RUN npm ci --only=production
# Copy application source
COPY . .
# Expose the app port
# EXPOSE 3000
# Environment variable
ENV NODE_ENV=production
# Start the application
CMD ["node", "src/index.js"]

1395
backend/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

19
backend/package.json Normal file
View File

@@ -0,0 +1,19 @@
{
"name": "backend",
"version": "1.0.0",
"description": "",
"license": "ISC",
"author": "",
"type": "commonjs",
"main": "src/index.js",
"scripts": {
"dev": "nodemon src/index.js"
},
"dependencies": {
"cors": "^2.8.6",
"dotenv": "^17.3.1",
"express": "^5.2.1",
"mongoose": "^9.3.0",
"nodemon": "^3.1.14"
}
}

14
backend/src/db.js Normal file
View 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;

32
backend/src/index.js Normal file
View File

@@ -0,0 +1,32 @@
const express = require("express");
const cors = require('cors');
const dotenv = require('dotenv');
if(process.env.NODE_ENV) {
dotenv.config({
path: `.env.${process.env.NODE_ENV}`
});
} else {
dotenv.config();
}
const app = express();
const connectDB = require("./db");
// connect database
connectDB();
app.use(cors({
origin: 'http://localhost:3000',
credentials: true, // if using cookies/auth
}));
app.get("/api/test", (req, res) => {
console.log("Hey");
res.json({"message": "Hello from backend!"});
});
app.listen(5000, () => {
console.log("Server running on port 5000");
});