full project: admin panel, backend modules, docs
This commit is contained in:
@@ -2,6 +2,7 @@ import { Controller, Get, Patch, Param, Body, UseGuards, Req } from '@nestjs/com
|
||||
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||||
import { UsersService } from './users.service';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { UpdateUserDto, FcmTokenDto } from '../auth/dto/auth.dto';
|
||||
|
||||
@ApiTags('Users')
|
||||
@Controller('users')
|
||||
@@ -9,30 +10,35 @@ export class UsersController {
|
||||
constructor(private users: UsersService) {}
|
||||
|
||||
@Get()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findAll() {
|
||||
return this.users.findAll();
|
||||
findAll(@Req() req) {
|
||||
const page = +(req.query.page || 1);
|
||||
const limit = +(req.query.limit || 20);
|
||||
return this.users.findAll(page, limit);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
@Get('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
findById(@Param('id') id: string) {
|
||||
return this.users.findById(id);
|
||||
findMe(@Req() req) {
|
||||
return this.users.findById(req.user.sub);
|
||||
}
|
||||
|
||||
@Patch('me')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
update(@Req() req, @Body() data: any) {
|
||||
return this.users.update(req.user.sub, data);
|
||||
update(@Req() req, @Body() dto: UpdateUserDto) {
|
||||
return this.users.update(req.user.sub, dto);
|
||||
}
|
||||
|
||||
@Patch('fcm-token')
|
||||
@Patch('me/fcm-token')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
updateFcmToken(@Req() req, @Body() dto: { token: string }) {
|
||||
updateFcmToken(@Req() req, @Body() dto: FcmTokenDto) {
|
||||
return this.users.updateFcmToken(req.user.sub, dto.token);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findById(@Param('id') id: string) {
|
||||
return this.users.findById(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user