File size: 608 Bytes
abc493d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { Body, Controller, ForbiddenException, Get, Patch, Request, UseGuards } from '@nestjs/common';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
import { SettingsService } from './settings.service';

@Controller('settings')
@UseGuards(JwtAuthGuard)
export class SettingsController {
  constructor(private svc: SettingsService) {}

  @Get()
  findAll() { return this.svc.findAll(); }

  @Patch()
  update(@Body() body: Record<string, string>, @Request() req: { user: { role: string } }) {
    if (req.user.role !== 'admin') throw new ForbiddenException();
    return this.svc.update(body);
  }
}