-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (28 loc) · 1.07 KB
/
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
const express = require('express');
const app = express();
const cors = require("cors");
const dotenv = require("dotenv");
const corsConFig = require('./config/cors.config');
const cookieParser = require("cookie-parser");
const { connectToMongoDB } = require('./config/database.config');
connectToMongoDB()
dotenv.config();
app.use(express.json());
app.use(cookieParser());
app.use(express.urlencoded({ extended: true }));
app.use(cors(corsConFig));
const authRouter = require('./routes/auth.routes');
const postsRouter = require('./routes/posts.routes');
const userRouter = require('./routes/user.routes');
const commentsRouter = require('./routes/comments.routes');
const likeRouter = require('./routes/likes.routes')
const bookmarkRouter = require("./routes/bookmark.routes");
app.use('/api', authRouter);
app.use('/api', userRouter);
app.use('/api', postsRouter);
app.use('/api', likeRouter);
app.use('/api', commentsRouter);
app.use('/api', bookmarkRouter);
const PORT = process.env.PORT || 4000;
app.listen(PORT, () => console.log('server running at ' + PORT));
module.exports = app;