-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart.js
More file actions
43 lines (36 loc) · 1.12 KB
/
start.js
File metadata and controls
43 lines (36 loc) · 1.12 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
var express = require('express');
var app = express();
const server = require('http').Server(app);
const path = require('path');
const jsdom = require('jsdom');
const io = require('socket.io').listen(server);
const { JSDOM } = jsdom;
var port = process.env.PORT || 1234;
function setupAuthoritativePhaser() {
JSDOM.fromFile(path.join(__dirname, 'js/server/index.html'), {
// To run the scripts in the html file
runScripts: "dangerously",
// Also load supported external resources
resources: "usable",
// So requestAnimatinFrame events fire
pretendToBeVisual: true
}).then((dom) => {
dom.window.gameLoaded = () => {
server.listen(port, function () {
console.log('HawaiianFactory Server on port ' + port + '!');
});
};
dom.window.io = io;
}).catch((error) => {
console.log(error.message);
});
}
app.use(express.static('assets/'))
app.use(express.static('js/'))
app.use(express.static('js/classes/'))
app.use(express.static('js/stats/'))
app.use(express.static('public/'))
app.get('/', function (req, res) {
res.sendFile('/index.html');
});
setupAuthoritativePhaser();