correction de l'erreur avec exclude
This commit is contained in:
@@ -5,12 +5,10 @@ import { UsersModule } from './users/users.module';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
import { FriendshipsModule } from './friendship/friendships.module';
|
||||
import { AuthenticationController } from './auth/authentication.controller';
|
||||
|
||||
@Module({
|
||||
imports: [UsersModule,
|
||||
FriendshipsModule,
|
||||
// RouterModule.register(routesForUsers),
|
||||
ConfigModule.forRoot(),
|
||||
TypeOrmModule.forRoot({
|
||||
type: 'postgres',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Exclude } from 'class-transformer';
|
||||
import { IsEmail, IsString } from 'class-validator';
|
||||
import { Unique } from 'typeorm';
|
||||
|
||||
export class CreateUsersDto {
|
||||
@IsString()
|
||||
@@ -7,6 +7,5 @@ export class CreateUsersDto {
|
||||
@IsEmail()
|
||||
readonly email: string;
|
||||
@IsString()
|
||||
@Exclude()
|
||||
readonly password: string;
|
||||
}
|
||||
|
||||
@@ -5,25 +5,20 @@ import { Friendship } from "../../friendship/entities/friendship.entity";
|
||||
|
||||
|
||||
@Entity('user')
|
||||
// @Unique(['email', 'username'])
|
||||
@Unique(['email', 'username'])
|
||||
export class User {
|
||||
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
@Length(5, 25)
|
||||
username: string;
|
||||
|
||||
|
||||
@Column()
|
||||
@IsEmail()
|
||||
email: string;
|
||||
|
||||
//Dans le cadre d'un tableau on peut faire :
|
||||
// @Column('json', { nullable: true })
|
||||
@Column()
|
||||
// @Exclude()
|
||||
password: string;
|
||||
|
||||
@Column('json', { nullable: true })
|
||||
@@ -36,8 +31,4 @@ export class User {
|
||||
@JoinTable()
|
||||
@OneToMany(type => Friendship , (friendship) => friendship.addresseeId)
|
||||
addresseeId: Friendship[];
|
||||
|
||||
// constructor(partial: Partial<User>) {
|
||||
// Object.assign(this, partial);
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -26,8 +26,9 @@ export class UsersController {
|
||||
}
|
||||
|
||||
@Post()
|
||||
@HttpCode(HttpStatus.GONE)
|
||||
@HttpCode(HttpStatus.CREATED)
|
||||
create(@Body() createUsersDto : CreateUsersDto ) {
|
||||
console.log(createUsersDto);
|
||||
return this.usersService.create(createUsersDto);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ export class UsersService {
|
||||
}
|
||||
|
||||
async update(id: string, updateUserDto: UpdateUsersDto) {
|
||||
console.log(`Update user ${id} with ${updateUserDto}`);
|
||||
const user = await this.userRepository.preload(
|
||||
{id: +id,
|
||||
...updateUserDto});
|
||||
|
||||
Reference in New Issue
Block a user