users api

This commit is contained in:
vigdorov
2020-07-26 16:42:00 +03:00
parent 7c62c57f2d
commit baeded4a7a
6 changed files with 250 additions and 21 deletions

View File

@ -1,13 +1,13 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';
import {ApiProperty} from '@nestjs/swagger';
import { Document } from 'mongoose';
interface Token {
token: string;
expired_at: string;
}
export class UserRequest {
export class CreateUserRequest {
@ApiProperty()
login: string;
@ -15,7 +15,46 @@ export class UserRequest {
avatar: string;
@ApiProperty()
is_admin: string;
password: string;
}
export class UpdateUserRequest {
@ApiProperty()
login: string;
@ApiProperty()
avatar: string;
}
export class UserResponse {
@ApiProperty()
login: string;
@ApiProperty()
avatar: string;
@ApiProperty()
is_admin: boolean;
}
export class UserModel {
@ApiProperty()
login: string;
@ApiProperty()
avatar: string;
@ApiProperty()
password: string;
@ApiProperty()
is_admin: boolean;
@ApiProperty()
access_token: Token[];
@ApiProperty()
refresh_token: Token[];
}
@Schema()
@ -44,20 +83,40 @@ export class User extends Document {
is_admin: boolean;
@Prop({
type: {
type: [{
token: String,
expired_at: String,
}
}]
})
access_token: Token;
access_token: Token[];
@Prop({
type: {
type: [{
token: String,
expired_at: String,
}
}]
})
refresh_token: Token;
refresh_token: Token[];
}
@Schema()
export class UserUpdate extends Document {
@Prop({
required: true,
type: String,
})
login: string;
@Prop({
type: String,
})
avatar: string;
@Prop({
type: Boolean,
})
is_admin: boolean;
}
export const UserUpdateSchema = SchemaFactory.createForClass(UserUpdate);
export const UserSchema = SchemaFactory.createForClass(User);