users api
This commit is contained in:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user