-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
35 lines (26 loc) · 917 Bytes
/
index.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
const config = require('./config/conf.js'),
uuid = require('node-uuid'),
{ JSDOM } = require('jsdom'),
request = require('ajax-request'),
jsdom = new JSDOM('<html></html>'),
{ window } = jsdom,
{ document } = window;
// https://swas.io/blog/use-jquery-jsdom-v11/
global.window = window;
global.document = document;
const $ = global.jQuery = require( 'jquery' );
let server = null;
if (config.https) {
const fs = require('fs'),
https = require('https');
const options = {
key: fs.readFileSync(config.key),
cert: fs.readFileSync(config.cert),
};
server = https.createServer(options).listen(config.port);
} else {
const http = require('http');
server = http.createServer().listen(config.port);
}
const io = require('socket.io').listen(server);
require('./src/Server/node/lobby.js')(io, $, uuid, request);