-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
53 lines (45 loc) · 1.46 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
// IMPORTS
const http2 = require('http2')
const fs = require('fs');
const path = require('path');
const mysql = require('mysql');
const Vector = require(path.resolve( __dirname, "./vector.js" ));
const Map = require(path.resolve( __dirname, "./map.js" ));
const Obstacle = require(path.resolve( __dirname, "./obstacle.js" ));
const Entities = require(path.resolve( __dirname, "./entities.js" ));
const Match = require(path.resolve( __dirname, "./match.js" ));
const User = require(path.resolve( __dirname, "./user.js" ));
const config = require(path.resolve( __dirname, "./config.js" ));
// CONFIGS
const port = 8080;
global.db;
//INITIALISE DB
global.db = mysql.createConnection(config["db"]);
global.db.connect(function(err) {
if (err){
console.log("DB Connection failed");
console.log(err);
}else{
console.log("DB Connection established");
}
});
//User.updateUserDataProperty(16,["stats","wonFights"],15).then(function(){});
// SERVER
const server = http2.createSecureServer({
key: fs.readFileSync(path.resolve( __dirname, './config/private-key.pem')),
cert: fs.readFileSync(path.resolve( __dirname, './config/cert.pem'))
});
server.on('error', (err) => console.error(err));
server.on('stream', (stream, headers) => {
// stream is a Duplex
stream.respond({
'content-type': 'text/html',
':status': 200
});
stream.write('<h1>Hello World</h1>');
});
server.setTimeout(0); //dectivate Timeout
server.listen(1443);
// Tick
setInterval(function(){
},33);