-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
85 lines (72 loc) · 3.18 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
const express = require("express");
const mongoose = require("mongoose");
const app = express();
const UserRoute = require('./route/userRoute');
const ContactMessageRoute = require('./route/contactMessageRoute');
const topicDomainRoute = require('./route/topicDomainRoute');
const topicRoutes = require('./route/topicRoute');
const keywordRoutes = require('./route/keywordRoute');
const readerArticle = require('./route/readerArticleRoute');
const comment = require('./route/commentRoute');
const flaggedTopicRoute = require('./route/flaggedTopicRoute')
const article = require('./route/articleRoute')
const fileRoutes = require('./route/fileRoutes')
const userUtilRoute = require('./route/userUtilRoute')
const auth = require('./middleware/auth');
const admin = require('./middleware/admin');
const authRoutes = require('./route/authRoutes');
const followRoutes = require('./route/followRoute');
const viewRoutes = require('./route/viewRoutes');
const likeRoutes = require('./route/likeRoutes');
const reportedArticle = require('./route/reportedArticleRoute');
const approvalRoutes = require('./route/articleApprovalRoute');
const reportedWriter = require('./route/reportedWriterRoute');
const deactivatedWriter = require('./route/deactivatedWriterRoute');
const rejectedArticle= require('./route/rejectedArticleRoute');
const notificationRoute = require('./route/notificationsRoute');
const articleDomainRoute = require('./route/articleDomainRoute');
const blockedArticleRoute = require('./route/blockedArticleRoute');
const dotenv = require('dotenv');
dotenv.config();
const bodyParser = require('body-parser')
const PORT = 3001;
// Increase the payload size limit
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));
var cors = require('cors');
app.use(cors());
mongoose.connect(process.env.URI)
.then(() => {
console.log("Successfully Connected to the MongoDB Database");
})
.catch(error => {
console.log("MongoDB connection error", error);
});
app.use('/api/auth', authRoutes);
app.use('/api/user', UserRoute); //http://localhost:3001/api/user
app.use ('/api/user-util', auth, admin, userUtilRoute);
app.use('/api/contactMessage', ContactMessageRoute);
app.use('/api/topicDomains', auth, topicDomainRoute);
app.use('/api/topics',auth, topicRoutes);
app.use('/api/keywords', auth, keywordRoutes);
app.use('/api/readerArticle', readerArticle);
app.use('/api/comment', comment);
app.use('/api/reportArticle', auth, reportedArticle);
app.use('/api/reportedWriter', auth, reportedWriter);
app.use('/api/deactivatedWriter', auth, deactivatedWriter);
app.use('/api/rejectedArticle',auth, rejectedArticle);
app.use('/api/flaggedTopics', flaggedTopicRoute);
app.use('/api/article', auth, article)
app.use('/api/file', fileRoutes)
app.use('/api/follow', followRoutes)
app.use('/api/like',likeRoutes)
app.use('/api/approval', auth, admin, approvalRoutes)
app.use('/api/notification', notificationRoute);
app.use('/api/view', viewRoutes)
app.use('/api/articleDomain',auth, articleDomainRoute);
app.use('/api/blockedArticle', blockedArticleRoute);
app.listen(PORT, () => {
console.log(`listening on port ${PORT}`);
});
// Export the app instance
module.exports = app;