Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backend/scripts/openapi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generateOpenApi } from "@ts-rest/open-api";
import { contract } from "@monkeytype/contracts/index";
import { COMPATIBILITY_CHECK, contract } from "@monkeytype/contracts/index";
import { writeFileSync, mkdirSync } from "fs";
import { EndpointMetadata, PermissionId } from "@monkeytype/contracts/util/api";
import type { OpenAPIObject, OperationObject } from "openapi3-ts";
Expand All @@ -24,7 +24,7 @@ export function getOpenApi(): OpenAPIObject {
title: "Monkeytype API",
description:
"Documentation for the endpoints provided by the Monkeytype API server.\n\nNote that authentication is performed with the Authorization HTTP header in the format `Authorization: ApeKey YOUR_APE_KEY`\n\nThere is a rate limit of `30 requests per minute` across all endpoints with some endpoints being more strict. Rate limit rates are shared across all ape keys.",
version: "2.0.0",
version: `2.${COMPATIBILITY_CHECK}.0`,
termsOfService: "https://monkeytype.com/terms-of-service",
contact: {
name: "Support",
Expand Down
8 changes: 5 additions & 3 deletions backend/src/middlewares/rate-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import MonkeyError from "../utils/error";
import type { Response, NextFunction, Request } from "express";
import { RateLimiterMemory } from "rate-limiter-flexible";
import {
ipKeyGenerator,
rateLimit,
RateLimitRequestHandler,
type Options,
Expand Down Expand Up @@ -40,12 +41,13 @@ export const customHandler = (
};

const getKey = (req: Request, _res: Response): string => {
return (
const ip =
(req.headers["cf-connecting-ip"] as string) ||
(req.headers["x-forwarded-for"] as string) ||
(req.ip as string) ||
"255.255.255.255"
);
"255.255.255.255";
const key = ipKeyGenerator(ip);
return key;
};

const getKeyWithUid = (
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/ts/commandline/commandline-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import * as ConfigSchemas from "@monkeytype/schemas/configs";
import * as SoundController from "../controllers/sound-controller";
import * as TestLogic from "../test/test-logic";
import { getLanguageDisplayString } from "../utils/strings";
import {
getLanguageDisplayString,
replaceUnderscoresWithSpaces,
} from "../utils/strings";

import { areUnsortedArraysEqual } from "../utils/arrays";
import { Config } from "../config/store";
Expand Down Expand Up @@ -531,7 +534,7 @@ export const commandlineConfigMetadata: CommandlineConfigMetadataObject = {
timerStyle: {
subgroup: {
options: "fromSchema",
display: (value) => value.replaceAll(/_/g, " "),
display: replaceUnderscoresWithSpaces,
},
alias: "timer",
},
Expand All @@ -554,6 +557,7 @@ export const commandlineConfigMetadata: CommandlineConfigMetadataObject = {
highlightMode: {
subgroup: {
options: "fromSchema",
display: replaceUnderscoresWithSpaces,
},
},
typedEffect: {
Expand Down Expand Up @@ -639,6 +643,7 @@ export const commandlineConfigMetadata: CommandlineConfigMetadataObject = {
keymapStyle: {
subgroup: {
options: "fromSchema",
display: replaceUnderscoresWithSpaces,
},
alias: "keyboard",
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/ts/components/mount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import { LoginPage } from "./pages/login/LoginPage";
import { ProfilePage } from "./pages/profile/ProfilePage";
import { ProfileSearchPage } from "./pages/profile/ProfileSearchPage";
import { SettingsPage } from "./pages/settings/SettingsPage";
import { TestModesNotice } from "./pages/test/modes-notice/TestModesNotice";
import { TestConfig } from "./pages/test/TestConfig";
import { Popups } from "./popups/Popups";
import { TestModesNotice } from "./test/modes-notice/TestModesNotice";

const components: Record<string, () => JSXElement> = {
footer: () => <Footer />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export function Theme(): JSXElement {
onClick={() => {
showSimpleModal({
title: "Share custom theme",
schema: z.object({ includeBackground: z.boolean() }),
schema: z.object({ includeBackground: z.boolean().optional() }),
inputs: {
includeBackground: {
label: "Include background link, size and filters",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createMemo, JSXElement } from "solid-js";

import { useUserAverage10LiveQuery } from "../../../collections/results";
import { getConfig } from "../../../config/store";
import { getFormatting, isAuthenticated } from "../../../states/core";
import { useUserAverage10LiveQuery } from "../../../../collections/results";
import { getConfig } from "../../../../config/store";
import { getFormatting, isAuthenticated } from "../../../../states/core";
import { Notice } from "./Notice";

export function AverageNotice(): JSXElement {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ParentProps, Show } from "solid-js";

import { CommandlineSubgroupKey } from "../../../commandline/types";
import { showCommandLineForConfig } from "../../../states/core";
import { FaSolidIcon } from "../../../types/font-awesome";
import { cn } from "../../../utils/cn";
import { OneOf } from "../../../utils/types";
import { Button } from "../../common/Button";
import { Fa } from "../../common/Fa";
import { CommandlineSubgroupKey } from "../../../../commandline/types";
import { showCommandLineForConfig } from "../../../../states/core";
import { FaSolidIcon } from "../../../../types/font-awesome";
import { cn } from "../../../../utils/cn";
import { OneOf } from "../../../../utils/types";
import { Button } from "../../../common/Button";
import { Fa } from "../../../common/Fa";
export function Notice(
props: {
when: boolean | undefined;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createMemo } from "solid-js";

import { getConfig } from "../../../config/store";
import { getLocalPB } from "../../../db";
import { getFormatting, isAuthenticated } from "../../../states/core";
import { getSnapshot } from "../../../states/snapshot";
import { getCurrentQuote } from "../../../states/test";
import { getActiveFunboxes } from "../../../test/funbox/list";
import { getMode2 } from "../../../utils/misc";
import { getConfig } from "../../../../config/store";
import { getLocalPB } from "../../../../db";
import { getFormatting, isAuthenticated } from "../../../../states/core";
import { getSnapshot } from "../../../../states/snapshot";
import { getCurrentQuote } from "../../../../states/test";
import { getActiveFunboxes } from "../../../../test/funbox/list";
import { getMode2 } from "../../../../utils/misc";
import { Notice } from "./Notice";

export function PbNotice() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { createMemo } from "solid-js";

import { useActiveTagsLiveQuery } from "../../../collections/tags";
import * as Commandline from "../../../commandline/commandline";
import { getConfig } from "../../../config/store";
import { useActiveTagsLiveQuery } from "../../../../collections/tags";
import * as Commandline from "../../../../commandline/commandline";
import { getConfig } from "../../../../config/store";
import {
getCustomTextIndicator,
getFormatting,
showCommandLineForConfig,
} from "../../../states/core";
import { hotkeys } from "../../../states/hotkeys";
} from "../../../../states/core";
import { hotkeys } from "../../../../states/hotkeys";
import {
getFocus,
getLoadedChallenge,
Expand All @@ -17,14 +17,14 @@ import {
isRepeated,
wordsHaveNewline,
wordsHaveTab,
} from "../../../states/test";
import { getActiveFunboxNames } from "../../../test/funbox/list";
import { cn } from "../../../utils/cn";
} from "../../../../states/test";
import { getActiveFunboxNames } from "../../../../test/funbox/list";
import { cn } from "../../../../utils/cn";
import {
getLanguageDisplayString,
replaceUnderscoresWithSpaces,
} from "../../../utils/strings";
import { Kbd } from "../../common/Kbd";
} from "../../../../utils/strings";
import { Kbd } from "../../../common/Kbd";
import { AverageNotice } from "./AverageNotice";
import { Notice } from "./Notice";
import { PbNotice } from "./PbNotice";
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/src/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const AddResultRequestSchema = z.object({
export type AddResultRequest = z.infer<typeof AddResultRequestSchema>;

export const ReportCompletedEventMismatchRequestSchema = z.object({
notMatching: z.array(z.string().max(100)).max(50),
mismatchedKeys: z.array(z.string().max(100)).max(50),
notMatching: z.array(z.string().max(10000)).max(50),
mismatchedKeys: z.array(z.string().max(10000)).max(50),
groupKey: z.string().max(500),
language: LanguageSchema.optional(),
mode: ModeSchema.optional(),
Expand Down
Loading