Добавлен контроллер пользователей, описана схема, подключен сервис для работы с БД, описана первая ручка для получения списка пользователей

This commit is contained in:
vigdorov
2020-07-26 00:53:58 +03:00
parent 8a809db67d
commit 7c62c57f2d
11 changed files with 392 additions and 54 deletions

63
src/users/users.schema.ts Normal file
View File

@ -0,0 +1,63 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import {ApiProperty} from '@nestjs/swagger';
interface Token {
token: string;
expired_at: string;
}
export class UserRequest {
@ApiProperty()
login: string;
@ApiProperty()
avatar: string;
@ApiProperty()
is_admin: string;
}
@Schema()
export class User extends Document {
@Prop({
required: true,
unique: true,
type: String,
})
login: string;
@Prop({
required: true,
type: String,
})
password: string;
@Prop({
type: String,
})
avatar: string;
@Prop({
type: Boolean,
})
is_admin: boolean;
@Prop({
type: {
token: String,
expired_at: String,
}
})
access_token: Token;
@Prop({
type: {
token: String,
expired_at: String,
}
})
refresh_token: Token;
}
export const UserSchema = SchemaFactory.createForClass(User);