mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-28 16:54:04 +08:00
* Migrate some utils to TS * Add argument type * Fix logic * Refactor math functions * Rename function
57 lines
1 KiB
TypeScript
57 lines
1 KiB
TypeScript
import _ from "lodash";
|
|
|
|
type Status = {
|
|
code: number;
|
|
message: string;
|
|
};
|
|
|
|
type Statuses = {
|
|
TEST_TOO_SHORT: Status;
|
|
RESULT_HASH_INVALID: Status;
|
|
RESULT_DATA_INVALID: Status;
|
|
RESULT_SPACING_INVALID: Status;
|
|
MISSING_KEY_DATA: Status;
|
|
BOT_DETECTED: Status;
|
|
GIT_GUD: Status;
|
|
};
|
|
|
|
const statuses: Statuses = {
|
|
TEST_TOO_SHORT: {
|
|
code: 460,
|
|
message: "Test too short",
|
|
},
|
|
RESULT_HASH_INVALID: {
|
|
code: 461,
|
|
message: "Result hash invalid",
|
|
},
|
|
RESULT_SPACING_INVALID: {
|
|
code: 462,
|
|
message: "Result spacing invalid",
|
|
},
|
|
RESULT_DATA_INVALID: {
|
|
code: 463,
|
|
message: "Result data invalid",
|
|
},
|
|
MISSING_KEY_DATA: {
|
|
code: 464,
|
|
message: "Missing key data",
|
|
},
|
|
BOT_DETECTED: {
|
|
code: 465,
|
|
message: "Bot detected",
|
|
},
|
|
GIT_GUD: {
|
|
code: 469,
|
|
message: "Git gud scrub",
|
|
},
|
|
};
|
|
|
|
const CUSTOM_STATUS_CODES = new Set(
|
|
_.map(statuses, (status: Status) => status.code)
|
|
);
|
|
|
|
export function isCustomCode(code: number): boolean {
|
|
return CUSTOM_STATUS_CODES.has(code);
|
|
}
|
|
|
|
export default statuses;
|