forked from NobleMathews/backend-team
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
92 lines (81 loc) · 3.06 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
const express = require('express')
const mongoose = require('mongoose')
const bodyParser = require('body-parser')
const session = require('express-session')
const cors = require('cors')
const cookieParser = require('cookie-parser')
const connection = require('./db/mongoose')
const passport = require('passport')
var flash = require('connect-flash')
// const methodOverride = require('method-override')
const adminRouter = require('./routes/admin')
const branchRouter = require('./routes/branch')
const clubHeadRouter = require('./routes/club_head')
const clubMembersRouter = require('./routes/club_members')
const clubsRouter = require('./routes/club')
const eventsRouter = require('./routes/events')
const imagesRouter = require('./routes/supporting/images')
const fileRouter = require('./routes/supporting/files')
const projectRouter = require('./routes/projects')
const achievementsRouter = require('./routes/achievements')
const notifyRouter = require('./routes/supporting/notify')
const blogRouter = require('./routes/blog')
const newsRouter = require('./routes/news')
const frontEndRouter = require('./routes/front')
const techteamRouter = require('./routes/tech_teams')
const publicRouter = require('./routes/public')
const committeeRouter = require('./routes/committee')
const editorRouter = require('./routes/editor')
const challengesRouter = require('./routes/challenges')
const contributorsRouter = require('./routes/contributors')
const app = express()
const port = process.env.PORT || 5000
app.use(session({ secret: 'test', saveUninitialized: true, resave: true }))
app.use(cors())
app.use(cookieParser())
app.use(passport.initialize());
app.use(passport.session());
app.use(bodyParser.urlencoded({ extended: true }))
app.use(bodyParser.json())
app.set('view engine', 'ejs')
app.set('useFindAndModify', false)
app.use(flash())
app.set('json spaces', 2)
app.use( express.static( "public" ) );
app.use('/admin', adminRouter)
app.use('/branches',branchRouter)
app.use('/club_head', clubHeadRouter)
app.use('/club_members', clubMembersRouter)
app.use('/events', eventsRouter)
app.use('/club', clubsRouter)
app.use('/images', imagesRouter)
app.use('/files', fileRouter)
app.use('/projects', projectRouter)
app.use('/achievements', achievementsRouter)
app.use('/notify', notifyRouter)
app.use('/blog', blogRouter)
app.use('/news', newsRouter)
app.use('/front', frontEndRouter)
app.use('/tech_teams', techteamRouter)
app.use('/public', publicRouter)
app.use('/committee_members', committeeRouter)
app.use('/editor', editorRouter)
app.use('/challenges',challengesRouter)
app.use('/contributors',contributorsRouter)
app.listen(port, () => {
console.log(`listening on port : ${port}`)
})
let gfs
connection.once('open', () => {
gfs = new mongoose.mongo.GridFSBucket(connection.db, { bucketName: 'uploads' })
app.locals.gfs = gfs
})
app.get('/', (req, res) => {
res.render('index', { alerts: req.flash('error') })
})
app.get('/admin/', (req, res) => {
res.render('adminLogin', { alerts: req.flash('error') })
})
app.get('/editor/', (req, res) => {
res.render('blog_editor', { alerts: req.flash('error') })
})