Initial commit

This commit is contained in:
Jakob Kordež
2023-09-04 22:10:54 +02:00
commit f24d39b4e1
59 changed files with 9378 additions and 0 deletions

View File

@ -0,0 +1,46 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { HydratedDocument, ObjectId } from 'mongoose';
import * as bcrypt from 'bcrypt';
import { Role } from 'src/enums/role.enum';
export type UserDocument = HydratedDocument<User>;
@Schema()
export class User {
_id: ObjectId;
@Prop({ required: true })
username: string;
@Prop({
required: true,
transform: () => undefined,
set: (value: string) => bcrypt.hashSync(value, 10),
})
password: string;
@Prop({
default: [Role.User],
type: [
{ type: String, enum: [Role.User.toString(), Role.Admin.toString()] },
],
})
roles: Role[];
@Prop({ required: true })
name: string;
@Prop()
email: string;
@Prop()
phone: string;
@Prop({
transform: () => undefined,
set: (value: string) => bcrypt.hashSync(value, 10),
})
auth: string;
}
export const UserSchema = SchemaFactory.createForClass(User);