-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
60 lines (52 loc) · 1.92 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
/**
* Created by pupboss on 3/10/16.
*/
'use strict';
var config = require('./config');
var express = require('express');
var useragent = require('express-useragent');
var body_parser = require('body-parser');
var compression = require('compression');
var token_parser = require('./middleware/token_parser');
var url_parser = require('./middleware/url_parser');
var app = express();
var index = require('./routes/index');
var account = require('./routes/account');
var student = require('./routes/student');
var grades = require('./routes/grades');
var unpass = require('./routes/unpass');
var exam_plan = require('./routes/exam_plan');
var extra_score = require('./routes/extra_score');
var class_table = require('./routes/class_table');
var course_eva = require('./routes/course_eva');
var feedback = require('./routes/feedback');
var appl = require('./routes/application');
var cors = require('cors');
var schedule = require('node-schedule');
var request = require('request');
app.disable('x-powered-by');
app.use(body_parser.urlencoded({ extended: false }));
app.use(useragent.express());
app.use(compression());
app.use(cors());
app.use('/', index);
app.use('/account', account);
app.use('/application', appl);
app.use(token_parser);
app.param(['id'], url_parser);
app.use('/student/:id', student);
app.use('/grades/:id', grades);
app.use('/unpass-course/:id', unpass);
app.use('/exam-plan/:id', exam_plan);
app.use('/skill-test-score/:id', extra_score);
app.use('/class-table/:id', class_table);
app.use('/course-eva-info/:id', course_eva);
app.use('/feedback', feedback);
var server = app.listen(config.port, function () {
console.log('LNTUOnline app listening at http://%s:%s', server.address().address, server.address().port);
});
var auto_fix = schedule.scheduleJob('*/1 * * * *', function () {
request('http://localhost:' + server.address().port + '/application/auto-fix', function (error, response, body) {
console.log(body);
});
});