added to routes for the user auth
All checks were successful
gitea/MERN_STACK_TEMPLATE/pipeline/head This commit looks good
All checks were successful
gitea/MERN_STACK_TEMPLATE/pipeline/head This commit looks good
This commit is contained in:
0
backend/controllers/auth.controller.js
Normal file
0
backend/controllers/auth.controller.js
Normal file
11
backend/db/connectDB.js
Normal file
11
backend/db/connectDB.js
Normal 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
1
backend/example.env
Normal file
@ -0,0 +1 @@
|
||||
MONGO_URI=mongodb://admin:test@localhost:27017/
|
0
backend/models/user.model.js
Normal file
0
backend/models/user.model.js
Normal file
20
backend/routes/auth.route.js
Normal file
20
backend/routes/auth.route.js
Normal 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
|
@ -1,5 +1,11 @@
|
||||
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();
|
||||
|
||||
app.get("/", (req, res) => {
|
||||
@ -7,6 +13,10 @@ app.get("/", (req, res) => {
|
||||
});
|
||||
|
||||
|
||||
app.use("/api/auth", authRoutes)
|
||||
|
||||
|
||||
app.listen(8080, () => {
|
||||
connectDB();
|
||||
console.log("Server Started at 0.0.0.0:8080");
|
||||
});
|
||||
|
@ -1 +1 @@
|
||||
docker-compose -f docker-compose.dev.yaml up --build
|
||||
docker-compose -f docker-compose.dev.yaml up --build -d
|
Reference in New Issue
Block a user