added to routes for the user auth
All checks were successful
gitea/MERN_STACK_TEMPLATE/pipeline/head This commit looks good

This commit is contained in:
2025-05-02 13:24:52 +02:00
parent a781c563d0
commit 7333cf79bd
7 changed files with 43 additions and 1 deletions

View File

11
backend/db/connectDB.js Normal file
View File

@ -0,0 +1,11 @@
import mongoose from "mongoose";
export const connectDB = async () => {
try {
const conn = await mongoose.connect(process.env.MONGO_URI);
console.log(`MongoDB Connected: ${conn.connection.host}`);
} catch(error) {
console.log("Error connection to MongoDB: ", error.message);
process.exit(1);
}
}

1
backend/example.env Normal file
View File

@ -0,0 +1 @@
MONGO_URI=mongodb://admin:test@localhost:27017/

View File

View File

@ -0,0 +1,20 @@
import express from "express";
const router = express.Router();
router.get("/signup", (req, res) => {
res.send("Signup route");
})
router.get("/login", (req, res) => {
res.send("Signup route");
})
router.get("/logout", (req, res) => {
res.send("Signup route");
})
export default router;
// https://youtu.be/pmvEgZC55Cg?t=1028

View File

@ -1,5 +1,11 @@
import express from "express"; import express from "express";
import dotenv from "dotenv";
import {connectDB} from "./db/connectDB.js";
import authRoutes from "./routes/auth.route.js"
dotenv.config();
const app = express(); const app = express();
app.get("/", (req, res) => { app.get("/", (req, res) => {
@ -7,6 +13,10 @@ app.get("/", (req, res) => {
}); });
app.use("/api/auth", authRoutes)
app.listen(8080, () => { app.listen(8080, () => {
connectDB();
console.log("Server Started at 0.0.0.0:8080"); console.log("Server Started at 0.0.0.0:8080");
}); });

View File

@ -1 +1 @@
docker-compose -f docker-compose.dev.yaml up --build docker-compose -f docker-compose.dev.yaml up --build -d