-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
32 lines (25 loc) · 883 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const express = require("express");
const connectDB = require("./database/db");
const dotenv = require("dotenv");
const cors = require("cors");
const authRoutes = require("./routes/auth");
const habitsRoutes = require("./routes/habit");
const GitRoutes = require("./routes/git");
const JournalRoutes = require("./routes/journal");
dotenv.config();
const app = express();
app.use(express.json()); // For parsing JSON payloads
app.use(cors());
// Connect to the database
connectDB();
// Simple test route
app.get("/", (req, res) => res.send("API is running"));
// Define your routes (we'll add the signup route here)
app.use("/api/auth", authRoutes);
app.use("/api/habits", habitsRoutes);
app.use("/api/git", GitRoutes);
app.use("/api/journal", JournalRoutes);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`);
});