diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-03-04 22:01:45 +0100 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-03-04 22:01:45 +0100 |
commit | 56c9e4377712e1a13e4d4f391ac0cf34cfb6e91d (patch) | |
tree | 35e7e6b28314ab209295164a910cbe72a5573126 /src/util | |
parent | [Users] @me self + guilds (diff) | |
download | server-56c9e4377712e1a13e4d4f391ac0cf34cfb6e91d.tar.xz |
:sparkles: Schema
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Config.ts | 2 | ||||
-rw-r--r-- | src/util/Event.ts | 2 | ||||
-rw-r--r-- | src/util/instanceOf.ts | 47 |
3 files changed, 24 insertions, 27 deletions
diff --git a/src/util/Config.ts b/src/util/Config.ts index cfdb0d1e..cd225407 100644 --- a/src/util/Config.ts +++ b/src/util/Config.ts @@ -45,6 +45,7 @@ export interface DefaultOptions { ttsCharacters: number; maxReactions: number; maxAttachmentSize: number; + maxBulkDelete: number; }; channel: { maxPins: number; @@ -124,6 +125,7 @@ export const DefaultOptions: DefaultOptions = { ttsCharacters: 200, maxReactions: 20, maxAttachmentSize: 8388608, + maxBulkDelete: 100, }, channel: { maxPins: 50, diff --git a/src/util/Event.ts b/src/util/Event.ts index 31838583..43c51d5c 100644 --- a/src/util/Event.ts +++ b/src/util/Event.ts @@ -8,3 +8,5 @@ export async function emitEvent(payload: Omit<Event, "created_at">) { return await new EventModel(obj).save(); } + +export async function emitAuditLog(payload: any) {} diff --git a/src/util/instanceOf.ts b/src/util/instanceOf.ts index b5b2f587..bbb30c12 100644 --- a/src/util/instanceOf.ts +++ b/src/util/instanceOf.ts @@ -114,35 +114,10 @@ export function instanceOf( } if (typeof type === "object") { - if (type?.constructor?.name != "Object") { - if (type instanceof Tuple) { - if ((<Tuple>type).types.some((x) => instanceOf(x, value, { path, optional, errors, req, ref }))) - return true; - throw new FieldError( - "BASE_TYPE_CHOICES", - req.t("common:field.BASE_TYPE_CHOICES", { types: type.types }) - ); - } else if (type instanceof Length) { - let length = <Length>type; - if (instanceOf(length.type, value, { path, optional, req, ref, errors }) !== true) return errors; - let val = ref.obj[ref.key]; - if ((<Length>type).check(val)) return true; - throw new FieldError( - "BASE_TYPE_BAD_LENGTH", - req.t("common:field.BASE_TYPE_BAD_LENGTH", { - length: `${type.min} - ${type.max}`, - }) - ); - } - if (value instanceof type) return true; - throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type })); - } - if (typeof value !== "object") - throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT")); + if (typeof value !== "object") throw new FieldError("BASE_TYPE_OBJECT", req.t("common:field.BASE_TYPE_OBJECT")); if (Array.isArray(type)) { - if (!Array.isArray(value)) - throw new FieldError("BASE_TYPE_ARRAY", req.t("common:field.BASE_TYPE_ARRAY")); + if (!Array.isArray(value)) throw new FieldError("BASE_TYPE_ARRAY", req.t("common:field.BASE_TYPE_ARRAY")); if (!type.length) return true; // type array didn't specify any type return ( @@ -159,6 +134,24 @@ export function instanceOf( ); }) || errors ); + } else if (type?.constructor?.name != "Object") { + if (type instanceof Tuple) { + if ((<Tuple>type).types.some((x) => instanceOf(x, value, { path, optional, errors, req, ref }))) return true; + throw new FieldError("BASE_TYPE_CHOICES", req.t("common:field.BASE_TYPE_CHOICES", { types: type.types })); + } else if (type instanceof Length) { + let length = <Length>type; + if (instanceOf(length.type, value, { path, optional, req, ref, errors }) !== true) return errors; + let val = ref.obj[ref.key]; + if ((<Length>type).check(val)) return true; + throw new FieldError( + "BASE_TYPE_BAD_LENGTH", + req.t("common:field.BASE_TYPE_BAD_LENGTH", { + length: `${type.min} - ${type.max}`, + }) + ); + } + if (value instanceof type) return true; + throw new FieldError("BASE_TYPE_CLASS", req.t("common:field.BASE_TYPE_CLASS", { type })); } const diff = Object.keys(value).missing( |