mirror of
https://github.com/CaramelFur/Picsur.git
synced 2025-11-14 15:45:49 +01:00
better shared api calls
This commit is contained in:
66
shared/src/dto/auth.dto.ts
Normal file
66
shared/src/dto/auth.dto.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import {
|
||||
IsBoolean,
|
||||
IsDefined,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsInt,
|
||||
ValidateNested,
|
||||
} from 'class-validator';
|
||||
import { User } from './user.dto';
|
||||
|
||||
// Api
|
||||
|
||||
export class AuthLoginRequest {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
username: string;
|
||||
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
password: string;
|
||||
}
|
||||
|
||||
export class AuthLoginResponse {
|
||||
@IsString()
|
||||
@IsDefined()
|
||||
access_token: string;
|
||||
}
|
||||
|
||||
export class AuthRegisterRequest {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
username: string;
|
||||
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
password: string;
|
||||
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
isAdmin?: boolean;
|
||||
}
|
||||
|
||||
export class AuthDeleteRequest {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
username: string;
|
||||
}
|
||||
|
||||
export class AuthDeleteResponse extends User {}
|
||||
|
||||
// Extra
|
||||
|
||||
export class JwtDataDto {
|
||||
@ValidateNested()
|
||||
@IsDefined()
|
||||
user: User;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
iat?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsInt()
|
||||
exp?: number;
|
||||
}
|
||||
Reference in New Issue
Block a user