Skip to content

Commit

Permalink
Update typings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlecDusheck committed Jan 10, 2019
1 parent 61f7e53 commit 862f8a2
Show file tree
Hide file tree
Showing 18 changed files with 76 additions and 102 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# SS
app.log
config.json
dist.zip

# compiled output
/dist
/tmp
Expand All @@ -10,6 +15,7 @@

# IDEs and editors
/.idea
.idea
.project
.classpath
.c9/
Expand Down
9 changes: 4 additions & 5 deletions src/api/certManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {SSManager} from "../ssmanager";
import * as proc from "child_process";
import * as util from "util";

class CertManager {
public ensureCerts = async () => {
export class CertManager {
public ensureCerts = async (): Promise<void> => {
try {
await fs.stat(path.join(SSManager.getRoot(), "../certs/server.cert"));
await fs.stat(path.join(SSManager.getRoot(), "../certs/server.key"));
Expand All @@ -16,14 +16,14 @@ class CertManager {
}
};

public getOptions = async () => {
public getOptions = async (): Promise<object> => {
return {
key: await fs.readFile(path.join(SSManager.getRoot(), "../certs/server.key")),
cert: await fs.readFile(path.join(SSManager.getRoot(), "../certs/server.cert"))
}
};

private generateCerts = async () => {
private generateCerts = async (): Promise<void> => {
await new Promise((resolve, reject) => {
proc.exec(util.format(path.join(SSManager.getRoot(), "/bashScripts/generateSsl.sh") + " %s", SSManager.config.api.addr), {cwd: path.join(SSManager.getRoot(), "../certs/")}, (err) => {
if (err) return reject(err);
Expand All @@ -33,4 +33,3 @@ class CertManager {
};
}

export {CertManager}
6 changes: 2 additions & 4 deletions src/api/controllers/games.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {SSManager} from "../../ssmanager";

class GamesController {
export class GamesController {
public getGames = async (req, res, next) => {
res.json({games: SSManager.configsController.games});
};
}

export {GamesController}
}
6 changes: 2 additions & 4 deletions src/api/controllers/gameserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {SSManager} from "../../ssmanager";

import * as async from "async";

class ServersController {
export class ServersController {
public getGameservers = async (req, res, next) => {
const serverList = [];

Expand Down Expand Up @@ -444,6 +444,4 @@ class ServersController {
server: newServer.getInfo()
});
}
}

export {ServersController}
}
6 changes: 2 additions & 4 deletions src/api/controllers/node.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as diskspace from "diskspace";
import * as osUtils from "os-utils";

class NodeController {
export class NodeController {
public getStatus = async (req, res, next) => {
osUtils.cpuUsage(function (cpu) {
diskspace.check('/', function (err, disk) {
Expand All @@ -27,6 +27,4 @@ class NodeController {
});
});
};
}

export {NodeController}
}
6 changes: 2 additions & 4 deletions src/api/controllers/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {SSManager} from "../../ssmanager";

class PluginsController {
export class PluginsController {
public getPlugins = async (req, res, next) => {
res.json({games: SSManager.configsController.plugins});
};
}

export {PluginsController}
}
11 changes: 5 additions & 6 deletions src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import {PluginsController} from "./controllers/plugins";
import {ServersController} from "./controllers/gameserver";
import {LoadedMiddleware} from "./middleware/loaded";
import {CertManager} from "./certManager";
import {Gameserver} from "../manager/controllers/gameserver/gameserver";

class APIServer {
export class APIServer {
public express;
public http;
public io;
Expand All @@ -32,7 +33,7 @@ class APIServer {
this.certManager = new CertManager();
}

public bootstrapExpress = async () => {
public bootstrapExpress = async (): Promise<void> => {
//Make sure certs are installed
await this.certManager.ensureCerts();

Expand Down Expand Up @@ -111,7 +112,7 @@ class APIServer {
await this.createHttp();
};

private createHttp = async () => {
private createHttp = async (): Promise<void> => {
SSManager.logger.verbose("HTTP server hosted on :" + SSManager.config.api.port);

this.http = https.createServer(await this.certManager.getOptions(), this.express);
Expand Down Expand Up @@ -161,6 +162,4 @@ class APIServer {

this.express.use('', apiRouter);
};
}

export {APIServer}
}
8 changes: 3 additions & 5 deletions src/manager/controllers/configs/configManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {SSManager} from "../../../ssmanager";
import {IGame} from "./gameConfig";
import {IPlugin} from "./pluginConfig";

class ConfigsController {
export class ConfigsController {
public games: Array<IGame>;
public plugins: Array<IPlugin>;

Expand All @@ -14,13 +14,11 @@ class ConfigsController {
this.dataFolder = dataFolder;
}

public loadGames = async () => {
public loadGames = async (): Promise<void> => {
this.games = await SSUtil.dirToJson(path.join(SSManager.getRoot(), this.dataFolder, "/games/"));
};

public loadPlugins = async () => {
public loadPlugins = async (): Promise<void> => {
this.plugins = await SSUtil.dirToJson(path.join(SSManager.getRoot(), this.dataFolder, "/plugins/"));
};
}

export { ConfigsController };
6 changes: 2 additions & 4 deletions src/manager/controllers/configs/gameConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
interface IGame {
export interface IGame {
name: string,
gamedig: {
active: boolean,
Expand All @@ -17,6 +17,4 @@ interface IGame {
useStdout: boolean,
},
verify: any
}

export {IGame}
}
6 changes: 2 additions & 4 deletions src/manager/controllers/configs/pluginConfig.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
interface IPlugin {
export interface IPlugin {
game: string,
name: string,
install: any,
remove: any
}

export {IPlugin}
}
6 changes: 2 additions & 4 deletions src/manager/controllers/configs/serverConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {IGame} from "./gameConfig";

interface IServer {
export interface IServer {
game: IGame,
id: string,
port: number,
Expand All @@ -12,6 +12,4 @@ interface IServer {
plugins: any,
installed: boolean,
players: number
}

export { IServer }
}
Loading

0 comments on commit 862f8a2

Please sign in to comment.