-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
30 lines (25 loc) · 847 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
const express = require('express');
const bodyParser = require('body-parser');
const dotenv = require('dotenv');
const connectDB = require('./config/db');
const session = require('express-session');
const authRoutes = require('./routes/authRoutes');
const todoRoutes = require('./routes/todoRoutes');
const { store } = require('./config/db');
dotenv.config();
const app = express();
app.use(session({
store,
secret: process.env.SESSION_SECRET || "makeittillyoucananymore32345",
resave: false,
saveUninitialized: false,
cookie: { secure: false }, // Set secure: true in production when using HTTPS
}))
app.use(bodyParser.json());
connectDB();
app.use('/api/auth', authRoutes);
app.use('/api', todoRoutes);
const PORT = process.env.PORT || 5000;
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
})