Fix code style errors

Remove extra whitespace, use more consistent spacing, add missing
semicolons, using dangling commas, break up long lines, consistent
multiline operator placement, add missing JSDoc strings and so on.
This commit is contained in:
Hornwitser committed 2023-11-19 04:48:38 +01:00
1 parent 97e05c0610
commit 7314dc99c8
71 files changed
+403 -290

No files matched your search

+14 -6
View File
@@ -56,13 +56,21 @@ export class ControllerPlugin extends lib.BaseControllerPlugin {
res.send(servers);
});
this.controller.app.post("/api/player_auth/player_code", express.json(), (req: Request, res: Response, next: any) => {
this.handlePlayerCode(req, res).catch(next);
});
this.controller.app.post(
"/api/player_auth/player_code",
express.json(),
(req: Request, res: Response, next: any) => {
this.handlePlayerCode(req, res).catch(next);
}
);
this.controller.app.post("/api/player_auth/verify", express.json(), (req: Request, res: Response, next: any) => {
this.handleVerify(req, res).catch(next);
});
this.controller.app.post(
"/api/player_auth/verify",
express.json(),
(req: Request, res: Response, next: any) => {
this.handleVerify(req, res).catch(next);
}
);
this.controller.handle(FetchPlayerCodeRequest, this.handleFetchPlayerCodeRequest.bind(this));
this.controller.handle(SetVerifyCodeRequest, this.handleSetVerifyCodeRequest.bind(this));
+8 -5
View File
@@ -2,7 +2,7 @@ import * as lib from "@clusterio/lib";
import { FetchPlayerCodeRequest, SetVerifyCodeRequest } from "./messages";
type ipcPlayerAuth = {
type IpcPlayerAuth = {
type: "open_dialog",
player: string,
} | {
@@ -17,12 +17,15 @@ export class InstancePlugin extends lib.BaseInstancePlugin {
throw new Error("player_auth plugin requires save patching.");
}
this.instance.server.on("ipc-player_auth", (ipcPlayerAuth: ipcPlayerAuth) => this.handleEvent(ipcPlayerAuth).catch(
err => this.logger.error(`Error handling event:\n${err.stack}`)
));
this.instance.server.on(
"ipc-player_auth",
(ipcPlayerAuth: IpcPlayerAuth) => this.handleEvent(ipcPlayerAuth).catch(
err => this.logger.error(`Error handling event:\n${err.stack}`)
)
);
}
async handleEvent(event: ipcPlayerAuth) {
async handleEvent(event: IpcPlayerAuth) {
if (event.type === "open_dialog") {
if (!this.host.connector.connected) {
await this.sendRcon(`/web-login error ${event.player} login is temporarily unavailable`);
+3 -3
View File
@@ -10,7 +10,7 @@ class FetchPlayerCodeResponse {
static jsonSchema = Type.Object({
"playerCode": Type.String(),
"controllerUrl": Type.String(),
})
});
static fromJSON(json: Static<typeof FetchPlayerCodeResponse.jsonSchema>): FetchPlayerCodeResponse {
return new this(json.playerCode, json.controllerUrl);
@@ -32,7 +32,7 @@ export class FetchPlayerCodeRequest {
static jsonSchema = Type.Object({
"player": Type.String(),
})
});
static fromJSON(json: Static<typeof FetchPlayerCodeRequest.jsonSchema>): FetchPlayerCodeRequest {
return new this(json.player);
@@ -55,7 +55,7 @@ export class SetVerifyCodeRequest {
static jsonSchema = Type.Object({
"player": Type.String(),
"verifyCode": Type.String(),
})
});
static fromJSON(json: Static<typeof SetVerifyCodeRequest.jsonSchema>): SetVerifyCodeRequest {
return new this(json.player, json.verifyCode);