diff options
-rw-r--r-- | api/src/middlewares/ErrorHandler.ts | 4 | ||||
-rw-r--r-- | api/src/util/String.ts | 2 | ||||
-rw-r--r-- | api/src/util/index.ts | 1 | ||||
-rw-r--r-- | api/src/util/route.ts | 2 | ||||
-rw-r--r-- | util/src/util/Email.ts | 2 | ||||
-rw-r--r-- | util/src/util/FieldError.ts (renamed from api/src/util/FieldError.ts) | 0 | ||||
-rw-r--r-- | util/src/util/index.ts | 3 |
7 files changed, 6 insertions, 8 deletions
diff --git a/api/src/middlewares/ErrorHandler.ts b/api/src/middlewares/ErrorHandler.ts index 96e703ce..2012b91c 100644 --- a/api/src/middlewares/ErrorHandler.ts +++ b/api/src/middlewares/ErrorHandler.ts @@ -1,8 +1,6 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server"; -import { EntityNotFoundError } from "typeorm"; -import { FieldError } from "@fosscord/api"; -import { ApiError } from "@fosscord/util"; +import { ApiError, FieldError } from "@fosscord/util"; const EntityNotFoundErrorRegex = /"(\w+)"/; export function ErrorHandler(error: Error, req: Request, res: Response, next: NextFunction) { diff --git a/api/src/util/String.ts b/api/src/util/String.ts index 67d87e37..982b7e11 100644 --- a/api/src/util/String.ts +++ b/api/src/util/String.ts @@ -1,6 +1,6 @@ import { Request } from "express"; import { ntob } from "./Base64"; -import { FieldErrors } from "./FieldError"; +import { FieldErrors } from "@fosscord/util"; export function checkLength(str: string, min: number, max: number, key: string, req: Request) { if (str.length < min || str.length > max) { diff --git a/api/src/util/index.ts b/api/src/util/index.ts index 3e47ce4e..238787c9 100644 --- a/api/src/util/index.ts +++ b/api/src/util/index.ts @@ -1,5 +1,4 @@ export * from "./Base64"; -export * from "./FieldError"; export * from "./ipAddress"; export * from "./Message"; export * from "./passwordStrength"; diff --git a/api/src/util/route.ts b/api/src/util/route.ts index 3e967e2a..e4794eb5 100644 --- a/api/src/util/route.ts +++ b/api/src/util/route.ts @@ -3,6 +3,7 @@ import { EVENT, Event, EventData, + FieldErrors, FosscordApiErrors, getPermission, PermissionResolvable, @@ -15,7 +16,6 @@ import fs from "fs"; import path from "path"; import Ajv from "ajv"; import { AnyValidateFunction } from "ajv/dist/core"; -import { FieldErrors } from ".."; import addFormats from "ajv-formats"; const SchemaPath = path.join(__dirname, "..", "..", "assets", "schemas.json"); diff --git a/util/src/util/Email.ts b/util/src/util/Email.ts index c304f584..b1a7599b 100644 --- a/util/src/util/Email.ts +++ b/util/src/util/Email.ts @@ -1,7 +1,7 @@ export const EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; -export function adjustEmail(email: string): string | undefined { +export function adjustEmail(email?: string): string | undefined { if (!email) return email; // body parser already checked if it is a valid email const parts = <RegExpMatchArray>email.match(EMAIL_REGEX); diff --git a/api/src/util/FieldError.ts b/util/src/util/FieldError.ts index 0b3f93d2..0b3f93d2 100644 --- a/api/src/util/FieldError.ts +++ b/util/src/util/FieldError.ts diff --git a/util/src/util/index.ts b/util/src/util/index.ts index 9c51d3b8..67583635 100644 --- a/util/src/util/index.ts +++ b/util/src/util/index.ts @@ -5,8 +5,9 @@ export * from "./cdn"; export * from "./Config"; export * from "./Constants"; export * from "./Database"; -export * from "./Event"; export * from "./Email"; +export * from "./Event"; +export * from "./FieldError"; export * from "./Intents"; export * from "./MessageFlags"; export * from "./Permissions"; |