Skip to content

Commit

Permalink
Setup backend with mvc architechture added proper routing
Browse files Browse the repository at this point in the history
  • Loading branch information
samar12-rad committed Oct 3, 2024
1 parent 13ca5e7 commit 9c4027e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions backend/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MONGO_URI=your-mongo-uri
3 changes: 1 addition & 2 deletions backend/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const app = express();
const port = 3000;
require("dotenv").config();
const mongoose = require("mongoose");
const { createReservation } = require("./controller/reservation.controller");

app.use(cors({}));

Expand All @@ -19,6 +18,6 @@ mongoose
console.error("Database connection failed:", error);
});

app.post("/create-reservation", createReservation);
app.post("/api", require("./routes/api"));

app.listen(port, () => console.log(`Server is running on port ${port}!`));
7 changes: 7 additions & 0 deletions backend/routes/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const express = require("express");

const router = express.Router();

router.use("/reservation", require("./reservation.router"));

module.exports = router;
7 changes: 7 additions & 0 deletions backend/routes/reservation.router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const express = require("express");
const { createReservation } = require("../controller/reservation.controller");
const router = express.Router();

router.post("./create", createReservation);

module.exports = router;

0 comments on commit 9c4027e

Please sign in to comment.