-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
38 lines (31 loc) · 956 Bytes
/
app.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
37
38
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const cookieParser = require('cookie-parser');
const connectDB = require('./config/database');
const cloudinary = require('./config/cloudinaryConfig');
const app = express();
// Initialize cookie-parser right after Express
app.use(cookieParser());
app.use(express.json());
app.use(
cors({
origin: 'http://localhost:3000', // replace with your frontend application's URL
credentials: true,
})
);
// Connect to MongoDB
connectDB();
// Import routes
const rugTypeRoutes = require('./routes/rugTypeRoute');
const rugRoutes = require('./routes/rugRoute');
const userRoutes = require('./routes/userRoute');
// Routes
app.use(rugTypeRoutes);
app.use(rugRoutes);
app.use(userRoutes);
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
});