-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (28 loc) · 816 Bytes
/
server.js
File metadata and controls
38 lines (28 loc) · 816 Bytes
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
import express from 'express';
import cors from 'cors';
import 'dotenv/config';
import cookieParser from 'cookie-parser';
import ConnectDB from './config/DB.js';
import authRoutes from './routes/authRoutes.js'
import userRoutes from './routes/userRoutes.js';
const app = express();
const Port = process.env.PORT || 3000 ;
//Connection of DB
ConnectDB();
app.use(express.json());
app.use(cookieParser());
app.use(cors({
origin:process.env.FRONTEND_URL,
credentials:true
}));
app.use((req, res, next) => {
res.header("Access-Control-Allow-Credentials", "true");
next();
});
// API Endpoints
app.get('/', (req, res) => {
res.send('APP is running 🚀');
});
app.use('/api/auth', authRoutes);
app.use('/api/user', userRoutes);
app.listen(Port,()=> console.log(`Server listening to port : ${Port}`));