feat: add jwt auth guard and profile endpoint
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import { Controller } from '@nestjs/common';
|
||||
import { Body, Controller, Get, Patch } from '@nestjs/common';
|
||||
import { UsersService } from './providers/users.service';
|
||||
import { ActiveUser } from '@/common/decorators/active-user.decorator';
|
||||
import { User } from './user.entity';
|
||||
import { UpdateProfileDTO } from './dto/update-profile.dto';
|
||||
|
||||
@Controller('users')
|
||||
export class UsersController {
|
||||
@@ -10,18 +13,16 @@ export class UsersController {
|
||||
private readonly usersService: UsersService,
|
||||
) {}
|
||||
|
||||
// @Get()
|
||||
// public getAllUsers() {
|
||||
// return ['user1', 'user2'];
|
||||
// }
|
||||
@Get('profile')
|
||||
public getUserProfile(@ActiveUser() user: User) {
|
||||
return this.usersService.getProfile(user);
|
||||
}
|
||||
|
||||
// @Get(':id')
|
||||
// public getUserById(@Param('id', ParseIntPipe) id: number) {
|
||||
// return `user ${id}`;
|
||||
// }
|
||||
|
||||
// @Post()
|
||||
// public async createUser(@Body() createUserDto: CreateUserDTO) {
|
||||
// return await this.usersService.createOne(createUserDto);
|
||||
// }
|
||||
@Patch('profile')
|
||||
public updateUserProfile(
|
||||
@ActiveUser() user: User,
|
||||
@Body() updateProfileDto: UpdateProfileDTO,
|
||||
) {
|
||||
return updateProfileDto;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user