forked from NabilaAhmedAdity/agent.v.2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
69 lines (57 loc) · 2.54 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
const express = require('express');
const app = express();
const server = require('http').createServer(app);
const path = require('path');
const rootPath = __dirname;
const flash = require('express-flash');
app.set('port', 3000);
app.set('view engine', 'pug');
app.set('views', path.join(rootPath, './views')); // It renders html from views folder
app.use('/public', express.static(path.join(rootPath, '/public')));
/* Configuration */
require('./configuration/bodyParser.js').addBodyParser(app);
require('./configuration/database.js');
require('./configuration/session.js').addSession(app);
app.use(flash());
/* Model */
require('./models/examModel.js');
require('./models/marksheetModel.js');
require('./models/courseModel.js');
require('./models/userModel.js');
require('./models/groupModel.js');
require('./models/submissionModel.js');
require('./models/preRegistration.js');
require('./models/fileModel.js')
require('./models/messageModel.js')
/* Route */
require('./controllers/landingPage/index.js').addRouter(app);
require('./controllers/general/profile.js').addRouter(app);
require('./controllers/general/profileEdit.js').addRouter(app);
require('./controllers/general/post.js').addRouter(app);
require('./controllers/general/group.js').addRouter(app);
require('./controllers/general/document.js').addRouter(app);
require('./controllers/general/discussion.js').addRouter(app);
require('./controllers/general/user.js').addRouter(app);
require('./controllers/general/course.js').addRouter(app);
require('./controllers/general/marksheet.js').addRouter(app);
require('./controllers/general/marksheetCSV.js').addRouter(app);
require('./controllers/general/marksheetAssessment.js').addRouter(app);
require('./controllers/general/marksheetStudent.js').addRouter(app);
require('./controllers/general/download.js').addRouter(app);
require('./controllers/general/resource.js').addRouter(app);
require('./controllers/general/submission.js').addRouter(app);
require('./controllers/facultyPage/faculty.js').addRouter(app);
require('./controllers/preRegistration/preRegistration.js').addRouter(app);
//Express error handling middleware
app.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).render('error', { title: '500', message: 'ReferenceError: error is not defined.' });
next();
});
// If no route match, shows 404 error
app.get('*', function(req, res) {
return res.status(404).render('error', { title: '404', message: 'Page not found.' });
});
server.listen(app.get('port'), function() {
console.log(`Server running at port ${app.get('port')}`);
});