summary refs log tree commit diff
path: root/util/oldModels/RateLimit.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-21 16:47:22 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-21 16:47:22 +0200
commitf711a0411cbe48319ea3497c4f26f872c18cd2a2 (patch)
tree681aa1e830c0bd9aba70af885139ad809476a779 /util/oldModels/RateLimit.ts
parent:art: update bundle build (diff)
downloadserver-f711a0411cbe48319ea3497c4f26f872c18cd2a2.tar.xz
:construction: typeorm
Diffstat (limited to 'util/oldModels/RateLimit.ts')
-rw-r--r--util/oldModels/RateLimit.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/util/oldModels/RateLimit.ts b/util/oldModels/RateLimit.ts
new file mode 100644

index 00000000..6a0e1ffd --- /dev/null +++ b/util/oldModels/RateLimit.ts
@@ -0,0 +1,25 @@ +import { Schema, Document, Types } from "mongoose"; +import db from "../util/Database"; + +export interface Bucket { + id: "global" | "error" | string; // channel_239842397 | guild_238927349823 | webhook_238923423498 + user_id: string; + hits: number; + blocked: boolean; + expires_at: Date; +} + +export interface BucketDocument extends Bucket, Document { + id: string; +} + +export const BucketSchema = new Schema({ + id: { type: String, required: true }, + user_id: { type: String, required: true }, // bot, user, oauth_application, webhook + hits: { type: Number, required: true }, // Number of times the user hit this bucket + blocked: { type: Boolean, required: true }, + expires_at: { type: Date, required: true }, +}); + +// @ts-ignore +export const BucketModel = db.model<BucketDocument>("Bucket", BucketSchema, "ratelimits");