-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (30 loc) · 1.02 KB
/
index.js
File metadata and controls
38 lines (30 loc) · 1.02 KB
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
33
34
35
36
37
38
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const authRoutes = require('./routes/authRoutes');
const taskRoutes = require('./routes/taskRoutes');
const workspaceRoutes = require('./routes/workspaceRoutes');
const app = express();
const PORT = process.env.PORT || 3000;
// --- MIDDLEWARES ---
app.use(express.json());
// --- END MIDDLEWARES ---
const dbConnectionString = process.env.MONGO_URI;
mongoose.connect(dbConnectionString)
.then(() => {
console.log("✅ MongoDB connection successful!");
})
.catch((err) => {
console.error("❌ MongoDB connection error:", err);
});
// --- ROUTES ---
app.use('/api/auth', authRoutes);
app.use('/api/tasks', taskRoutes);
app.use('/api/workspaces', workspaceRoutes); // Add the workspace routes
// --- END ROUTES ---
app.get('/', (req, res) => {
res.send('Server is running. TaskFlow API (with Workspaces) is ready!');
});
app.listen(PORT, () => {
console.log(`🚀 Server is now live on http://localhost:${PORT}`);
});