From 2e756b164930181826af3c9cd3f7dba8265c4815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Vest=C3=B8l?= Date: Tue, 12 Mar 2019 13:18:01 +0100 Subject: [PATCH] Master now compiles with typescript --- master.ts | 17 ++++++++++++++--- types/master.d.ts | 16 ++++++++++++++++ types/slaveMapper.d.ts | 3 +++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 types/master.d.ts create mode 100644 types/slaveMapper.d.ts diff --git a/master.ts b/master.ts index abaf084b..c6e95e28 100644 --- a/master.ts +++ b/master.ts @@ -276,7 +276,7 @@ POST World ID management. Slaves post here to tell the server they exist @instance @alias /api/getID */ -app.post("/api/getID", authenticate.middleware, function(req: Request,res: Response) { +app.post("/api/getID", authenticate.middleware, function(req, res) { endpointHitCounter.labels(req.route.path).inc(); // request.body should be an object // {rconPort, rconPassword, serverPort, mac, time} @@ -725,7 +725,7 @@ if(args.sslPort || config.sslPort){ var certificate = fs.readFileSync(path.resolve(config.databaseDirectory, 'certificates/cert.crt')); var privateKey = fs.readFileSync(path.resolve(config.databaseDirectory, 'certificates/cert.key')); - httpsServer = require("https").createServer({ + var httpsServer = require("https").createServer({ key: privateKey, cert: certificate }, app).listen(args.sslPort || config.sslPort); @@ -734,7 +734,7 @@ if(args.sslPort || config.sslPort){ } } if(args.masterPort || config.masterPort){ - server = require("http").Server(app); + var server = require("http").Server(app); server.listen(args.masterPort || config.masterPort || 8080, function () { console.log("Listening on port %s...", server.address().port); }); @@ -747,6 +747,9 @@ const ioMetrics = require("socket.io-prometheus"); ioMetrics(io); var slaveMappers = {}; class slaveMapper { + instanceID: string + socket: any + lastBeat: number constructor(instanceID, socket) { this.instanceID = instanceID; this.socket = socket; @@ -777,6 +780,10 @@ class slaveMapper { } var mapRequesters = {}; class mapRequester { + requesterID: string + socket: any + instanceID: string + lastBeat: number constructor(requesterID, socket, instanceID){ this.requesterID = requesterID; this.socket = socket; @@ -819,6 +826,10 @@ var wsSlaves = {}; var wsChatRecievers = []; var wsAlertRecievers = []; class wsSlave { + instanceID: string + socket: any + lastBeat: number + commandsWaitingForReturn: object constructor(instanceID, socket){ this.instanceID = instanceID; this.socket = socket; diff --git a/types/master.d.ts b/types/master.d.ts new file mode 100644 index 00000000..531d4785 --- /dev/null +++ b/types/master.d.ts @@ -0,0 +1,16 @@ +type MasterPluginInstance = { + config: object, + pluginConfig: object, + path: string, + socketio: any, + express: any, + Prometheus: any, + onExit?: Function, +} +type pluginConfig = { + name: string, +} +interface MasterPlugin { + main: MasterPluginInstance, + pluginConfig: pluginConfig, +} diff --git a/types/slaveMapper.d.ts b/types/slaveMapper.d.ts new file mode 100644 index 00000000..3df3d452 --- /dev/null +++ b/types/slaveMapper.d.ts @@ -0,0 +1,3 @@ +interface slaveMapper { + instanceID: string, +} \ No newline at end of file