-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
75 lines (68 loc) · 2.61 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
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
const express =require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const mongoose = require('mongoose');
require('dotenv').config();
const local_path = process.env.LOCAL_PATH;
const app = express();
const port =process.env.PORT || 4000;
app.use(cors());
app.use(bodyParser.json());
const uri = process.env.ATLAS_YURI;
mongoose.set('useCreateIndex', true);
mongoose.set('useFindAndModify', false);
mongoose.connect(uri, { useNewUrlParser: true, useUnifiedTopology: true })
.catch(error => console.log(error));
const connection = mongoose.connection;
connection.once('open', () => {
console.log("MongoDB database connection established successfully");
});
const lectureitemsRouter = require('./routes/LectureItems');
const CodeReviewRouter = require('./routes/CodeReview');
const UserRouter = require('./routes/Users');
const EmailRouter = require('./routes/EmailSend');
const CourseRouter = require('./routes/CourseList');
const LectureRouter = require('./routes/Lectures');
const AdminRouter = require('./routes/admin');
const EventRouter = require('./routes/Events');
const PaymentRouter = require('./routes/Payment');
const DoubtChatRouter = require('./routes/DoubtChatting');
const CommentRouter = require('./routes/CourseComment');
const FeedBackRouter = require('./routes/Feedback');
const SupportChat = require('./routes/SupportChat.js');
const PaymentListRouter = require('./routes/PaymentList.js');
const Invoice = require('./routes/Html_PDF.js');
const Blog = require('./routes/Blog.js');
const PushNotiRouter = require('./routes/PushNotification.js');
const test = require('./routes/test');
app.use('/admin', AdminRouter);
app.use('/lectureitem', lectureitemsRouter);
app.use('/codereview', CodeReviewRouter);
app.use('/user', UserRouter);
app.use('/emailsend', EmailRouter);
app.use('/course', CourseRouter);
app.use('/lecture', LectureRouter);
app.use('/event', EventRouter);
app.use('/payment', PaymentRouter);
app.use('/doubtchat', DoubtChatRouter);
app.use('/supportchat', SupportChat);
app.use('/comment', CommentRouter);
app.use('/feedback', FeedBackRouter);
app.use('/paymentlist', PaymentListRouter);
app.use('/invoice', Invoice);
app.use('/blog', Blog);
app.use('/pushnoti', PushNotiRouter);
app.use('/test', test);
app.get('/now_time_get', function(req, res){
var data = new Date();
res.send(data);
});
app.get('/audio_file_get/:filename', function(req, res){
res.sendFile(local_path+'audio/'+req.params.filename);
});
app.get('/logo_image', function(req, res){
res.sendFile(local_path+'logo.png');
})
app.listen(port, () => {
console.log('Server is running on port: '+port)
})