better shared api calls

This commit is contained in:
rubikscraft
2022-02-25 12:22:00 +01:00
parent 825b2856bb
commit 626e228991
37 changed files with 407 additions and 131 deletions

View 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;
}