This commit is contained in:
Alex Holliday committed 2026-01-16 22:03:35 +00:00
1 parent cb5b8e0673
commit 9c92542653
12 files changed
+154 -36

No files matched your search

+27
View File
@@ -0,0 +1,27 @@
import { Schema, model, type Types } from "mongoose";
import type { RecoveryToken as RecoveryTokenEntity } from "@/types/recoveryToken.js";
type RecoveryTokenDocumentBase = Omit<RecoveryTokenEntity, "id" | "createdAt" | "updatedAt" | "expiry"> & {
expiry: Date;
};
interface RecoveryTokenDocument extends RecoveryTokenDocumentBase {
_id: Types.ObjectId;
createdAt: Date;
updatedAt: Date;
}
const RecoveryTokenSchema = new Schema<RecoveryTokenDocument>(
{
email: { type: String, required: true, unique: true },
token: { type: String, required: true },
expiry: { type: Date, default: Date.now, expires: 600 },
},
{ timestamps: true }
);
const RecoveryTokenModel = model<RecoveryTokenDocument>("RecoveryToken", RecoveryTokenSchema);
export type { RecoveryTokenDocument };
export { RecoveryTokenModel };
export default RecoveryTokenModel;