-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
39 lines (37 loc) · 1.4 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
const express = require('express')
const cors = require('cors')
const app = express()
const connection = require('./db')
const authRoutes = require('./routes/auth')
const submitReviewRoutes = require('./routes/submitReview');
const addFeedBackRoutes = require('./routes/addFeedback')
const addCourseRoutes = require('./routes/addCourse')
const getAllCourseDetails = require('./utilities/getAllCourseDetails')
const getFeedbackPattern = require('./utilities/getFeedbackPattern')
const getRatings = require('./utilities/getRatings')
const isReviewed = require('./utilities/isReviewed')
const path = require('path');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
connection()
app.use(cors())
app.use(express.json())
app.use('/feedback/signin',authRoutes)
app.use('/feedback/review',submitReviewRoutes)
app.use('/addFeedBack', addFeedBackRoutes)
app.use('/addCourse', addCourseRoutes)
app.use('/getAllCourseDetails', getAllCourseDetails)
app.use('/getFeedbackPattern', getFeedbackPattern)
app.use('/getRatings',getRatings)
app.use('/isReviewed',isReviewed)
if(process.env.NODE_ENV === 'production'){
app.use(express.static('/build'))
app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname,'build','index.html'))
})
}
const port = process.env.PORT || 3001
app.listen(port, () => {
console.log('Server fired up at',port);
})