-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
36 lines (28 loc) · 924 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
33
34
35
36
// server.js
const express = require('express');
const connectDB = require('./config/db');
const app = express();
const cors = require('cors');
require('dotenv').config();
// Connect Database
connectDB();
// Init Middleware
app.use(express.json());
// CORS Configuration
app.use(
cors({
origin: 'http://localhost:3001', // Update this to your frontend's URL
credentials: true,
})
);
// Serve static files from 'public'
app.use('/public', express.static('public'));
// Define Routes
app.use('/api/auth', require('./routes/authRoutes'));
app.use('/api/user', require('./routes/userRoutes'));
app.use('/api/therapy', require('./routes/therapyRoutes'));
app.use('/api/blog', require('./routes/blogRoutes'));
app.use('/api/music', require('./routes/musicRoutes')); // Add music routes
// Define PORT
const PORT = process.env.PORT || 5001;
app.listen(PORT, () => console.log(`Server started on port ${PORT}`));