first commit v3 initialiazed a temporary repository for darmanet client

This commit is contained in:
2026-09-08 16:04:01 +03:30
commit 5c7fd95052
216 changed files with 30050 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
import * as crypto from 'node:crypto';
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { ChatModel } from './chat.model';
import { UsersBaseModel } from './users-base.model';
@Schema({
timestamps: { createdAt: 'createdAt', updatedAt: 'updatedAt' },
versionKey: false,
collection: 'user',
_id: true,
})
export class UserModel extends UsersBaseModel {
@Prop({ default: [] })
chat: ChatModel[];
@Prop({
required: false,
select: true,
set: (otp: string) =>
otp ? crypto.createHash('sha256').update(otp).digest('hex') : null,
expires: 120, // The OTP will automatically be removed after 120 seconds
})
otp: string | null;
@Prop({ type: Date, default: null })
otpCreatedAt: Date | null;
@Prop({ type: Number, default: 0 })
otpAttempts: number;
}
export const UserSchema = SchemaFactory.createForClass(UserModel);
UserSchema.pre('save', function (next) {
this.updatedAt = new Date();
next();
});