-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (31 loc) · 1.05 KB
/
index.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
39
40
41
import express from "express";
import postRoute from './routes/postRoutes.js'
import authRoute from './routes/authRoutes.js'
import testRoute from './routes/testRoutes.js'
import userRoute from './routes/userRoutes.js'
import chatRoute from './routes/chatRoutes.js'
import messageRoute from './routes/messageRoute.js'
import cookieParser from "cookie-parser";
import evar from 'dotenv';
import cors from 'cors';
const app = express();
// CORs resolution
// credentials: true will allows us to send cookies to client side
app.use(cors({ origin: process.env.CLIENT_URL, credentials: true }));
// configure environment variables
evar.config();
// to handle JSON data
app.use(express.json())
// using cookie parser
app.use(cookieParser())
app.use('/api/auth', authRoute);
app.use('/api/users', userRoute);
app.use('/api/posts', postRoute);
app.use('/api/test', testRoute);
app.use('/api/chats', chatRoute);
app.use('/api/messages', messageRoute);
console.log("test");
const portno = 8800
app.listen(portno, () => {
console.log(`Server is running on port: ${portno}`);
})