* feat: infra token module added * feat: infra token guard added * feat: token prefix removed * feat: get pending invites api added * docs: swagger doc added for get user invites api * feat: delete user invitation api added * feat: get users api added * feat: update user api added * feat: update admin status api added * feat: create invitation api added * chore: swagger doc update for create user invite * feat: interceptor added to track last used on * feat: change db schema * chore: readonly tag added * feat: get user by id api added * fix: return type of a function * feat: controller name change * chore: improve token extractino * chore: added email validation logic --------- Co-authored-by: Balu Babu <balub997@gmail.com>
115 lines
2.1 KiB
TypeScript
115 lines
2.1 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Expose, Transform, Type } from 'class-transformer';
|
|
import {
|
|
ArrayMinSize,
|
|
IsArray,
|
|
IsBoolean,
|
|
IsEmail,
|
|
IsNotEmpty,
|
|
IsOptional,
|
|
IsString,
|
|
MinLength,
|
|
} from 'class-validator';
|
|
import { OffsetPaginationArgs } from 'src/types/input-types.args';
|
|
|
|
// POST v1/infra/user-invitations
|
|
export class CreateUserInvitationRequest {
|
|
@Type(() => String)
|
|
@IsNotEmpty()
|
|
@ApiProperty()
|
|
inviteeEmail: string;
|
|
}
|
|
export class CreateUserInvitationResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
invitationLink: string;
|
|
}
|
|
|
|
// GET v1/infra/user-invitations
|
|
export class GetUserInvitationResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
inviteeEmail: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
invitedOn: Date;
|
|
}
|
|
|
|
// DELETE v1/infra/user-invitations
|
|
export class DeleteUserInvitationRequest {
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@Type(() => String)
|
|
@IsNotEmpty()
|
|
@ApiProperty()
|
|
inviteeEmails: string[];
|
|
}
|
|
export class DeleteUserInvitationResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
message: string;
|
|
}
|
|
|
|
// POST v1/infra/users
|
|
export class GetUsersRequestQuery extends OffsetPaginationArgs {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(1)
|
|
@ApiPropertyOptional()
|
|
searchString: string;
|
|
}
|
|
export class GetUserResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
uid: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
displayName: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
email: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
photoURL: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
isAdmin: boolean;
|
|
}
|
|
|
|
// PATCH v1/infra/users/:uid
|
|
export class UpdateUserRequest {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(1)
|
|
@ApiPropertyOptional()
|
|
displayName: string;
|
|
}
|
|
|
|
// PATCH v1/infra/users/:uid/admin-status
|
|
export class UpdateUserAdminStatusRequest {
|
|
@IsBoolean()
|
|
@IsNotEmpty()
|
|
@ApiProperty()
|
|
isAdmin: boolean;
|
|
}
|
|
export class UpdateUserAdminStatusResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
message: string;
|
|
}
|
|
|
|
// Used for Swagger doc only, in codebase throwHTTPErr function is used to throw errors
|
|
export class ExceptionResponse {
|
|
@ApiProperty()
|
|
@Expose()
|
|
message: string;
|
|
|
|
@ApiProperty()
|
|
@Expose()
|
|
statusCode: number;
|
|
}
|