Rename handlers to utils (#2620)

This commit is contained in:
Bruce Berrios 2022-03-03 16:31:57 -05:00 committed by GitHub
parent 0429c560ee
commit 374a2089c3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 45 additions and 51 deletions

View file

@ -2,9 +2,9 @@ import _ from "lodash";
import { randomBytes } from "crypto";
import { hash } from "bcrypt";
import ApeKeysDAO from "../../dao/ape-keys";
import MonkeyError from "../../handlers/error";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { base64UrlEncode } from "../../handlers/misc";
import MonkeyError from "../../utils/error";
import { MonkeyResponse } from "../../utils/monkey-response";
import { base64UrlEncode } from "../../utils/misc";
function cleanApeKey(apeKey: MonkeyTypes.ApeKey): Partial<MonkeyTypes.ApeKey> {
return _.omit(apeKey, "hash");

View file

@ -1,5 +1,5 @@
import ConfigDAO from "../../dao/config";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { MonkeyResponse } from "../../utils/monkey-response";
class ConfigController {
static async getConfig(req: MonkeyTypes.Request): Promise<MonkeyResponse> {

View file

@ -1,5 +1,5 @@
import _ from "lodash";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { MonkeyResponse } from "../../utils/monkey-response";
import LeaderboardsDAO from "../../dao/leaderboards";
class LeaderboardsController {

View file

@ -1,5 +1,5 @@
import PresetDAO from "../../dao/preset";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { MonkeyResponse } from "../../utils/monkey-response";
class PresetController {
static async getPresets(req: MonkeyTypes.Request): Promise<MonkeyResponse> {

View file

@ -1,5 +1,5 @@
import PsaDAO from "../../dao/psa";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { MonkeyResponse } from "../../utils/monkey-response";
class PsaController {
static async get(_req: MonkeyTypes.Request): Promise<MonkeyResponse> {

View file

@ -4,10 +4,10 @@ import UserDAO from "../../dao/user";
import ReportDAO from "../../dao/report";
import NewQuotesDao from "../../dao/new-quotes";
import QuoteRatingsDAO from "../../dao/quote-ratings";
import MonkeyError from "../../handlers/error";
import { verify } from "../../handlers/captcha";
import Logger from "../../handlers/logger";
import { MonkeyResponse } from "../../handlers/monkey-response";
import MonkeyError from "../../utils/error";
import { verify } from "../../utils/captcha";
import Logger from "../../utils/logger";
import { MonkeyResponse } from "../../utils/monkey-response";
class QuotesController {
static async getQuotes(_req: MonkeyTypes.Request): Promise<MonkeyResponse> {

View file

@ -2,12 +2,12 @@ import ResultDAO from "../../dao/result";
import UserDAO from "../../dao/user";
import PublicStatsDAO from "../../dao/public-stats";
import BotDAO from "../../dao/bot";
import { roundTo2, stdDev } from "../../handlers/misc";
import { roundTo2, stdDev } from "../../utils/misc";
import node_object_hash from "node-object-hash";
import Logger from "../../handlers/logger";
import Logger from "../../utils/logger";
import "dotenv/config";
import { MonkeyResponse } from "../../handlers/monkey-response";
import MonkeyError from "../../handlers/error";
import { MonkeyResponse } from "../../utils/monkey-response";
import MonkeyError from "../../utils/error";
import {
implemented as anticheatImplemented,
validateResult,

View file

@ -1,11 +1,11 @@
import _ from "lodash";
import UsersDAO from "../../dao/user";
import BotDAO from "../../dao/bot";
import MonkeyError from "../../handlers/error";
import Logger from "../../handlers/logger.js";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { linkAccount } from "../../handlers/discord";
import { buildAgentLog } from "../../handlers/misc";
import MonkeyError from "../../utils/error";
import Logger from "../../utils/logger.js";
import { MonkeyResponse } from "../../utils/monkey-response";
import { linkAccount } from "../../utils/discord";
import { buildAgentLog } from "../../utils/misc";
function cleanUser(user: MonkeyTypes.User): Omit<MonkeyTypes.User, "apeKeys"> {
return _.omit(user, "apeKeys");

View file

@ -7,7 +7,7 @@ import leaderboards from "./leaderboards";
import quotes from "./quotes";
import apeKeys from "./ape-keys";
import { asyncHandler } from "../../middlewares/api-utils";
import { MonkeyResponse } from "../../handlers/monkey-response";
import { MonkeyResponse } from "../../utils/monkey-response";
import { Application, NextFunction, Response } from "express";
import swStats from "swagger-stats";

View file

@ -4,7 +4,7 @@ import { Router } from "express";
import UserController from "../controllers/user";
import { asyncHandler, validateRequest } from "../../middlewares/api-utils";
import * as RateLimit from "../../middlewares/rate-limit";
import { isUsernameValid } from "../../handlers/validation";
import { isUsernameValid } from "../../utils/validation";
const router = Router();

View file

@ -1,7 +1,7 @@
import _ from "lodash";
import UsersDAO from "./user";
import { ObjectId } from "mongodb";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
function checkIfKeyExists(
apeKeys: MonkeyTypes.User["apeKeys"],

View file

@ -1,5 +1,5 @@
import db from "../init/db";
import Logger from "../handlers/logger";
import Logger from "../utils/logger";
import { performance } from "perf_hooks";
class LeaderboardsDAO {

View file

@ -4,7 +4,7 @@ import stringSimilarity from "string-similarity";
import path from "path";
import fs from "fs";
import db from "../init/db";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
let git;
try {

View file

@ -1,4 +1,4 @@
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
import db from "../init/db";
import { ObjectId } from "mongodb";

View file

@ -1,5 +1,5 @@
import db from "../init/db";
import { roundTo2 } from "../handlers/misc";
import { roundTo2 } from "../utils/misc";
class PublicStatsDAO {
//needs to be rewritten, this is public stats not user stats

View file

@ -1,4 +1,4 @@
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
import db from "../init/db";
class ReportDAO {
static async createReport(report, maxReports, contentReportLimit) {

View file

@ -1,5 +1,5 @@
import { ObjectId } from "mongodb";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
import db from "../init/db";
import UserDAO from "./user";

View file

@ -1,9 +1,9 @@
import _ from "lodash";
import { isUsernameValid } from "../handlers/validation";
import { updateAuthEmail } from "../handlers/auth";
import { checkAndUpdatePb } from "../handlers/pb";
import { isUsernameValid } from "../utils/validation";
import { updateAuthEmail } from "../utils/auth";
import { checkAndUpdatePb } from "../utils/pb";
import db from "../init/db";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
import { ObjectId } from "mongodb";
class UsersDAO {

View file

@ -1,7 +1,7 @@
import db from "./db";
import _ from "lodash";
import Logger from "../handlers/logger.js";
import { identity } from "../handlers/misc";
import Logger from "../utils/logger.js";
import { identity } from "../utils/misc";
import BASE_CONFIGURATION from "../constants/base-configuration";
const CONFIG_UPDATE_INTERVAL = 10 * 60 * 1000; // 10 Minutes

View file

@ -1,6 +1,6 @@
import { CronJob } from "cron";
import db from "../init/db";
import Logger from "../handlers/logger";
import Logger from "../utils/logger";
const CRON_SCHEDULE = "0 0 0 * * *";
const LOG_MAX_AGE_DAYS = 7;

View file

@ -1,11 +1,8 @@
import _ from "lodash";
import joi from "joi";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
import { Response, NextFunction, RequestHandler } from "express";
import {
handleMonkeyResponse,
MonkeyResponse,
} from "../handlers/monkey-response";
import { handleMonkeyResponse, MonkeyResponse } from "../utils/monkey-response";
import UsersDAO from "../dao/user";
interface ValidationOptions<T> {

View file

@ -1,9 +1,9 @@
import _ from "lodash";
import { compare } from "bcrypt";
import UsersDAO from "../dao/user";
import MonkeyError from "../handlers/error";
import { verifyIdToken } from "../handlers/auth";
import { base64UrlDecode } from "../handlers/misc";
import MonkeyError from "../utils/error";
import { verifyIdToken } from "../utils/auth";
import { base64UrlDecode } from "../utils/misc";
import { NextFunction, Response, Handler } from "express";
interface RequestAuthenticationOptions {

View file

@ -1,11 +1,8 @@
import db from "../init/db";
import { v4 as uuidv4 } from "uuid";
import Logger from "../handlers/logger";
import MonkeyError from "../handlers/error";
import {
MonkeyResponse,
handleMonkeyResponse,
} from "../handlers/monkey-response";
import Logger from "../utils/logger";
import MonkeyError from "../utils/error";
import { MonkeyResponse, handleMonkeyResponse } from "../utils/monkey-response";
import { NextFunction, Response } from "express";
async function errorHandlingMiddleware(

View file

@ -1,6 +1,6 @@
import { Response, NextFunction } from "express";
import rateLimit, { Options } from "express-rate-limit";
import MonkeyError from "../handlers/error";
import MonkeyError from "../utils/error";
const REQUEST_MULTIPLIER = process.env.MODE === "dev" ? 100 : 1;