Simple resource
A simplified version of the resource to prevent unnecessary complexity.
The focus will be on testing the CRUD operations of the users resource. Due to this, the next step will be to simplify this resource to the point when it was integrated with TypeORM, so we avoid adding too much complexity in the lessons. So, we can simplify the UsersModule...
@Module({
imports: [TypeOrmModule.forFeature([User])],
controllers: [UsersController],
providers: [UsersService],
})
export class UsersModule {}...the UsersController...
@Controller('users')
export class UsersController {
constructor(private readonly usersService: UsersService) {}
@Post()
create(@Body() createUserDto: CreateUserDto) {
return this.usersService.create(createUserDto);
}
@Get()
findAll() {
return this.usersService.findAll();
}
@Get(':id')
findOne(@Param() { id }: IdDto) {
return this.usersService.findOne(id);
}
@Patch(':id')
update(@Param() { id }: IdDto, @Body() updateUserDto: UpdateUserDto) {
return this.usersService.update(id, updateUserDto);
}
@Delete(':id')
remove(@Param() { id }: IdDto) {
return this.usersService.remove(id);
}
}...the UsersService...
...and in the User entity, remove the orders field.
We do this to be more straightforward in our studies. But don't worry, this will not be committed. At the end of this module, this will be stashed.
Last updated