mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-10 07:36:09 +08:00
build(backend): enable noPropertyAccessFromIndexSignature flag
This commit is contained in:
parent
e1dcd29419
commit
abbe77b01b
10 changed files with 26 additions and 24 deletions
|
@ -73,14 +73,14 @@ export async function getResults(
|
|||
: req.ctx.configuration.results.limits.regularUser;
|
||||
|
||||
const onOrAfterTimestamp = parseInt(
|
||||
req.query.onOrAfterTimestamp as string,
|
||||
req.query["onOrAfterTimestamp"] as string,
|
||||
10
|
||||
);
|
||||
let limit = stringToNumberOrDefault(
|
||||
req.query.limit as string,
|
||||
req.query["limit"] as string,
|
||||
Math.min(req.ctx.configuration.results.maxBatchSize, maxLimit)
|
||||
);
|
||||
const offset = stringToNumberOrDefault(req.query.offset as string, 0);
|
||||
const offset = stringToNumberOrDefault(req.query["offset"] as string, 0);
|
||||
|
||||
//check if premium features are disabled and current call exceeds the limit for regular users
|
||||
if (
|
||||
|
|
|
@ -26,7 +26,7 @@ import {
|
|||
} from "express";
|
||||
import { isDevEnvironment } from "../../utils/misc";
|
||||
|
||||
const pathOverride = process.env.API_PATH_OVERRIDE;
|
||||
const pathOverride = process.env["API_PATH_OVERRIDE"];
|
||||
const BASE_ROUTE = pathOverride ? `/${pathOverride}` : "";
|
||||
const APP_START_TIME = Date.now();
|
||||
|
||||
|
@ -66,7 +66,8 @@ function addApiRoutes(app: Application): void {
|
|||
app.use(
|
||||
(req: MonkeyTypes.Request, res: Response, next: NextFunction): void => {
|
||||
const inMaintenance =
|
||||
process.env.MAINTENANCE === "true" || req.ctx.configuration.maintenance;
|
||||
process.env["MAINTENANCE"] === "true" ||
|
||||
req.ctx.configuration.maintenance;
|
||||
|
||||
if (inMaintenance) {
|
||||
res.status(503).json({ message: "Server is down for maintenance" });
|
||||
|
|
|
@ -24,8 +24,8 @@ function addSwaggerMiddlewares(app: Application): void {
|
|||
swaggerSpec: internalSwaggerSpec,
|
||||
onAuthenticate: (_req, username, password) => {
|
||||
return (
|
||||
username === process.env.STATS_USERNAME &&
|
||||
password === process.env.STATS_PASSWORD
|
||||
username === process.env["STATS_USERNAME"] &&
|
||||
password === process.env["STATS_PASSWORD"]
|
||||
);
|
||||
},
|
||||
})
|
||||
|
|
|
@ -9,13 +9,13 @@ async function main(): Promise<void> {
|
|||
Queues.map(async (queue) => {
|
||||
const counts = await queue.getJobCounts();
|
||||
|
||||
const active = counts.active;
|
||||
const completed = counts.completed;
|
||||
const failed = counts.failed;
|
||||
const active = counts["active"];
|
||||
const completed = counts["completed"];
|
||||
const failed = counts["failed"];
|
||||
|
||||
const waiting = counts.waiting;
|
||||
const paused = counts.paused;
|
||||
const delayed = counts.delayed;
|
||||
const waiting = counts["waiting"];
|
||||
const paused = counts["paused"];
|
||||
const delayed = counts["delayed"];
|
||||
const waitingChildren = counts["waiting-children"];
|
||||
|
||||
const waitingTotal = waiting + paused + delayed + waitingChildren;
|
||||
|
|
|
@ -261,7 +261,7 @@ function authenticateGithubWebhook(): Handler {
|
|||
//authorize github webhook
|
||||
const { "x-hub-signature-256": authHeader } = req.headers;
|
||||
|
||||
const webhookSecret = process.env.GITHUB_WEBHOOK_SECRET;
|
||||
const webhookSecret = process.env["GITHUB_WEBHOOK_SECRET"];
|
||||
|
||||
try {
|
||||
if (!webhookSecret) {
|
||||
|
|
|
@ -18,8 +18,8 @@ import { createIndicies as leaderboardDbSetup } from "./dal/leaderboards";
|
|||
async function bootServer(port: number): Promise<Server> {
|
||||
try {
|
||||
Logger.info(`Starting server version ${version}`);
|
||||
Logger.info(`Starting server in ${process.env.MODE} mode`);
|
||||
Logger.info(`Connecting to database ${process.env.DB_NAME}...`);
|
||||
Logger.info(`Starting server in ${process.env["MODE"]} mode`);
|
||||
Logger.info(`Connecting to database ${process.env["DB_NAME"]}...`);
|
||||
await db.connect();
|
||||
Logger.success("Connected to database");
|
||||
|
||||
|
@ -81,6 +81,6 @@ async function bootServer(port: number): Promise<Server> {
|
|||
});
|
||||
}
|
||||
|
||||
const PORT = parseInt(process.env.PORT ?? "5005", 10);
|
||||
const PORT = parseInt(process.env["PORT"] ?? "5005", 10);
|
||||
|
||||
bootServer(PORT);
|
||||
|
|
|
@ -17,7 +17,7 @@ export async function verify(captcha: string): Promise<boolean> {
|
|||
{
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
||||
body: `secret=${process.env.RECAPTCHA_SECRET}&response=${captcha}`,
|
||||
body: `secret=${process.env["RECAPTCHA_SECRET"]}&response=${captcha}`,
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@ const warningColor = chalk.yellow.bold;
|
|||
const successColor = chalk.green.bold;
|
||||
const infoColor = chalk.white;
|
||||
|
||||
const logFolderPath = process.env.LOG_FOLDER_PATH ?? "./logs";
|
||||
const maxLogSize = parseInt(process.env.LOG_FILE_MAX_SIZE ?? "10485760");
|
||||
const logFolderPath = process.env["LOG_FOLDER_PATH"] ?? "./logs";
|
||||
const maxLogSize = parseInt(process.env["LOG_FILE_MAX_SIZE"] ?? "10485760");
|
||||
|
||||
interface Log {
|
||||
type?: string;
|
||||
|
@ -32,7 +32,7 @@ const timestampFormat = format.timestamp({
|
|||
});
|
||||
|
||||
const simpleOutputFormat = format.printf((log) => {
|
||||
return `${log.timestamp}\t${log.level}: ${log.message}`;
|
||||
return `${log["timestamp"]}\t${log.level}: ${log.message}`;
|
||||
});
|
||||
|
||||
const coloredOutputFormat = format.printf((log) => {
|
||||
|
@ -50,7 +50,7 @@ const coloredOutputFormat = format.printf((log) => {
|
|||
break;
|
||||
}
|
||||
|
||||
return `${log.timestamp}\t${color(log.message)}`;
|
||||
return `${log["timestamp"]}\t${color(log.message)}`;
|
||||
});
|
||||
|
||||
const fileFormat = format.combine(timestampFormat, simpleOutputFormat);
|
||||
|
|
|
@ -300,5 +300,5 @@ export function stringToNumberOrDefault(
|
|||
}
|
||||
|
||||
export function isDevEnvironment(): boolean {
|
||||
return process.env.MODE === "dev";
|
||||
return process.env["MODE"] === "dev";
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
"esModuleInterop": true,
|
||||
"strictNullChecks": true,
|
||||
"skipLibCheck": false,
|
||||
"noImplicitReturns": true
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true
|
||||
},
|
||||
"ts-node": {
|
||||
"files": true
|
||||
|
|
Loading…
Add table
Reference in a new issue