-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.js
More file actions
81 lines (74 loc) · 1.46 KB
/
app.js
File metadata and controls
81 lines (74 loc) · 1.46 KB
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
/**
* Created by rolyer on 15-4-8.
*/
// import modules here
var express = require('express'),
bodyParser = require('body-parser'),
http = require('http'),
cas = require('cas-client'),
config = require('./config'),
multipart = require('connect-multiparty'),
common = require('./routes/common');
var auth = cas.getMiddleware('http://sso.com:8080/cas', 'http://localhost:8000');
var app = express();
var server = http.createServer(app);
// set the view engine to ejs
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.engine('html', require('ejs').renderFile);
app.use(express.static(__dirname + '/public'));
// for parsing application/json
app.use(bodyParser.json());
// for parsing application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({ extended: true }));
/**
*
* chat index page
*
*/
app.get('/chat', common.chat);
/**
*
* init data
* e.g. http://localhost:8000/init
*
*/
app.get('/init', common.init);
/**
*
* fetch users/friends from database
*
*/
app.get('/friends', common.friends);
/**
*
* fetch chat history from database
*
*/
app.post('/history', common.history);
/**
*
* Fetch offline messages
*
*/
app.post('/offline', common.offline);
/**
*
* Update read status
*
*/
app.post('/update', common.update);
/**
*
* send message
*
*/
app.post('/message', common.message);
/**
*
* file upload
*
*/
app.post('/uploader', multipart(), common.uploader);
common.bayeux.attach(server);
server.listen(8000);