replace deprecated plainToClass with plainToInstance
This commit is contained in:
parent
643b448607
commit
6e9be6d827
3 changed files with 6 additions and 6 deletions
|
|
@ -3,7 +3,7 @@ import { CreateUserDto } from './dto/create-user.dto';
|
||||||
import { UpdateUserDto } from './dto/update-user.dto';
|
import { UpdateUserDto } from './dto/update-user.dto';
|
||||||
import { User } from './entities/user.entity';
|
import { User } from './entities/user.entity';
|
||||||
import { UserRepository } from './repositories/user.repository';
|
import { UserRepository } from './repositories/user.repository';
|
||||||
import { plainToClass } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
import * as bcrypt from 'bcrypt';
|
import * as bcrypt from 'bcrypt';
|
||||||
import { WorkspaceService } from '../workspace/services/workspace.service';
|
import { WorkspaceService } from '../workspace/services/workspace.service';
|
||||||
import { CreateWorkspaceDto } from '../workspace/dto/create-workspace.dto';
|
import { CreateWorkspaceDto } from '../workspace/dto/create-workspace.dto';
|
||||||
|
|
@ -21,7 +21,7 @@ export class UserService {
|
||||||
throw new BadRequestException('A user with this email already exists');
|
throw new BadRequestException('A user with this email already exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
let user: User = plainToClass(User, createUserDto);
|
let user: User = plainToInstance(User, createUserDto);
|
||||||
user.locale = 'en';
|
user.locale = 'en';
|
||||||
user.lastLoginAt = new Date();
|
user.lastLoginAt = new Date();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { WorkspaceRepository } from '../repositories/workspace.repository';
|
||||||
import { WorkspaceUserRepository } from '../repositories/workspace-user.repository';
|
import { WorkspaceUserRepository } from '../repositories/workspace-user.repository';
|
||||||
import { WorkspaceUser } from '../entities/workspace-user.entity';
|
import { WorkspaceUser } from '../entities/workspace-user.entity';
|
||||||
import { Workspace } from '../entities/workspace.entity';
|
import { Workspace } from '../entities/workspace.entity';
|
||||||
import { plainToClass } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
import { v4 as uuid } from 'uuid';
|
import { v4 as uuid } from 'uuid';
|
||||||
import { generateHostname } from '../workspace.util';
|
import { generateHostname } from '../workspace.util';
|
||||||
|
|
||||||
|
|
@ -19,7 +19,7 @@ export class WorkspaceService {
|
||||||
createWorkspaceDto: CreateWorkspaceDto,
|
createWorkspaceDto: CreateWorkspaceDto,
|
||||||
userId: string,
|
userId: string,
|
||||||
): Promise<Workspace> {
|
): Promise<Workspace> {
|
||||||
let workspace: Workspace = plainToClass(Workspace, createWorkspaceDto);
|
let workspace: Workspace = plainToInstance(Workspace, createWorkspaceDto);
|
||||||
|
|
||||||
workspace.inviteCode = uuid();
|
workspace.inviteCode = uuid();
|
||||||
workspace.creatorId = userId;
|
workspace.creatorId = userId;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { IsString, IsUrl, validateSync } from 'class-validator';
|
import { IsString, IsUrl, validateSync } from 'class-validator';
|
||||||
import { plainToClass } from 'class-transformer';
|
import { plainToInstance } from 'class-transformer';
|
||||||
|
|
||||||
export class EnvironmentVariables {
|
export class EnvironmentVariables {
|
||||||
@IsString()
|
@IsString()
|
||||||
|
|
@ -10,7 +10,7 @@ export class EnvironmentVariables {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function validate(config: Record<string, any>) {
|
export function validate(config: Record<string, any>) {
|
||||||
const validatedConfig = plainToClass(EnvironmentVariables, config);
|
const validatedConfig = plainToInstance(EnvironmentVariables, config);
|
||||||
|
|
||||||
const errors = validateSync(validatedConfig);
|
const errors = validateSync(validatedConfig);
|
||||||
if (errors.length > 0) {
|
if (errors.length > 0) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue