-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
40 lines (24 loc) · 778 Bytes
/
server.js
File metadata and controls
40 lines (24 loc) · 778 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
38
39
40
import cors from 'cors'
import dotenv from 'dotenv'
import express from 'express'
import { connectDB } from './lib/db.js';
import cookieParser from 'cookie-parser';
//! routers
import authRoutes from './routes/authRouter.js'
import messageRoutes from './routes/chatRouter.js'
import { app, server } from './lib/socket.js';
dotenv.config()
app.use(cors({
origin: "http://localhost:5173",
credentials: true,
}));
app.use(express.json({ limit: '100mb' }));
app.use(express.urlencoded({ limit: '100mb', extended: true }));
app.use(cookieParser())
app.use('/api/auth', authRoutes)
app.use('/api/message', messageRoutes)
const PORT = process.env.PORT || 8080;
server.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
connectDB()
})