Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a2e2089

Browse files
chore: lint code
1 parent 3cd9fd0 commit a2e2089

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

configs/webpack/common.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { resolve } = require("path");
44
const HtmlWebpackPlugin = require("html-webpack-plugin");
55
const CopyWebpackPlugin = require("copy-webpack-plugin");
6-
var webpack = require('webpack');
6+
var webpack = require("webpack");
77

88
module.exports = {
99
entry: "./index.tsx",
@@ -51,7 +51,10 @@ module.exports = {
5151
patterns: [{ from: "public" }],
5252
}),
5353
new webpack.DefinePlugin({
54-
'process.env.API_MODE': JSON.stringify(process.env.API_MODE),
55-
})
54+
// this way we will always have a fallback value
55+
"process.env.API_MODE": JSON.stringify(
56+
process.env.API_MODE ? process.env.API_MODE : "prod",
57+
),
58+
}),
5659
],
5760
};

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"build": "pnpm clean-dist && webpack --config=configs/webpack/prod.js",
3737
"clean-dist": "rimraf dist/*",
3838
"lint": "eslint \"./src/**/*.{js,ts,tsx}\" --quiet",
39+
"lintOnlyChanges": "eslint $(git diff --name-only HEAD | grep -E '\\.(js|ts|tsx)$' | xargs)",
3940
"start": "pnpm start-dev",
4041
"start-dev": "webpack serve --config=configs/webpack/dev.js --host 0.0.0.0 --port 3000",
4142
"start-prod": "pnpm build && node express.js"

src/api/JsonApi.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ const endPoints = {
66
dev: "https://homedev.gametools.network/api/",
77
prod: "https://manager-api.gametools.network/api/",
88
};
9-
const MODE = process.env.API_MODE ? process.env.API_MODE : "prod";
109

11-
console.log("API_MODE: " + MODE);
10+
const MODE = (() => {
11+
const mode_raw = process.env.API_MODE;
12+
if (mode_raw && mode_raw in endPoints) {
13+
return mode_raw;
14+
} else {
15+
return "prod";
16+
}
17+
})();
1218

1319
export const endPointName = endPoints[MODE].replace("https://", "").replace(
1420
"/api/",
@@ -55,7 +61,7 @@ export default class JsonClient {
5561
postJsonMethod(
5662
method: string,
5763
params: { [name: string]: unknown },
58-
): Promise<any> {
64+
): Promise<{ [name: string]: string }> {
5965
const options = {
6066
method: "POST",
6167
body: JSON.stringify(params),
@@ -69,7 +75,7 @@ export default class JsonClient {
6975
getJsonMethod(
7076
method: string,
7177
params: { [name: string]: string | number },
72-
): Promise<any> {
78+
): Promise<{ [name: string]: string }> {
7379
return this.errorHandler(this.fetchMethod(method, params));
7480
}
7581
async errorHandler(
@@ -109,18 +115,21 @@ export default class JsonClient {
109115
};
110116
}
111117
async getUserInfo(): Promise<IUserInfo> {
112-
const defaultUser = {
118+
const defaultUser: IUserInfo = {
113119
discord: {
114120
name: "",
115-
discriminator: 0,
121+
discriminator: "",
116122
avatar: "",
117123
},
124+
permissions: {
125+
isAdminOf: [],
126+
},
118127
auth: {
119-
inGuild: false,
120128
isAdmin: false,
121129
isDeveloper: false,
122130
isOwner: false,
123131
signedIn: false,
132+
isManager: false,
124133
},
125134
};
126135

0 commit comments

Comments
 (0)