forked from Yara724/api
33 lines
793 B
TypeScript
33 lines
793 B
TypeScript
import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose";
|
|
import { HydratedDocument } from "mongoose";
|
|
|
|
@Schema({
|
|
collection: "captcha-challenges",
|
|
timestamps: true,
|
|
versionKey: false,
|
|
})
|
|
export class CaptchaChallenge {
|
|
@Prop({ required: true, unique: true, index: true })
|
|
captchaId: string;
|
|
|
|
@Prop()
|
|
answerHash?: string;
|
|
|
|
@Prop({ required: true })
|
|
image: string;
|
|
|
|
@Prop({ required: true, index: true })
|
|
expiresAt: number;
|
|
|
|
/** Mongo TTL — document removed shortly after this time. */
|
|
@Prop({ required: true, expires: 0 })
|
|
expireAt: Date;
|
|
|
|
@Prop({ default: null })
|
|
usedAt?: Date | null;
|
|
}
|
|
|
|
export type CaptchaChallengeDocument = HydratedDocument<CaptchaChallenge>;
|
|
export const CaptchaChallengeSchema =
|
|
SchemaFactory.createForClass(CaptchaChallenge);
|