-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
54 lines (43 loc) · 1.95 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
var express = require('express');
var lessMiddleware = require('less-middleware');
var utils = require('./utilities.js');
var pluginLoader = require('./pluginLoader.js');
var connectionPool = require('./connectionPool.js');
var chatroom = require('./chatroom.js');
var activityLog = require('./activityLog.js');
var activityController = require('./activityController.js');
var chatController = require('./chatController.js');
var pluginsController = require('./pluginsController.js');
var filesController = require('./filesController.js');
var whiteboardController = require('./whiteboardController.js');
var _activityLog = new activityLog();
var _connectionPool = new connectionPool();
var _chatroom = new chatroom(_activityLog);
_chatroom.sendMessage('Server', 'Room created.');
var plugins = pluginLoader.load();
var _activityController = new activityController(_activityLog, _connectionPool, plugins);
var _chatController = new chatController(_chatroom);
var _pluginsController = new pluginsController(_activityLog, plugins, _chatroom);
var _filesController = new filesController(_activityLog);
var _whiteboardController = new whiteboardController(_activityLog);
var app = express();
app.use(express.query());
app.use(express.bodyParser());
app.post('/send', _chatController.send);
app.post('/join', _chatController.join);
app.post('/leave', _chatController.leave);
app.post('/alias', _chatController.alias);
app.post('/status', _chatController.status);
app.post('/whiteboard/edit', _whiteboardController.edit);
app.post('/whiteboard/clear', _whiteboardController.clear);
app.get('/update', _activityController.update);
app.post('/plugins/:name', _pluginsController.plugins);
app.post('/upload', _filesController.upload);
app.get('/download/:id', _filesController.download);
app.use(lessMiddleware('static'));
app.use(express.static('static'));
var port = 8080;
if (process.argv[2])
port = process.argv[2];
app.listen(port);
console.log('QChat now running on port ' + port);