21 lines
1.3 KiB
TypeScript
21 lines
1.3 KiB
TypeScript
|
|
import { Controller, Get, Post, Delete, Body, Param, UseGuards } from '@nestjs/common';
|
||
|
|
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
|
||
|
|
import { ContentSafetyService } from './content-safety.service';
|
||
|
|
import { AdminAuthGuard } from '../../common/guards/admin-auth.guard';
|
||
|
|
import { AdminRolesGuard } from '../../common/guards/admin-roles.guard';
|
||
|
|
import { AdminRoles } from '../../common/decorators/admin-roles.decorator';
|
||
|
|
import type { AdminRole } from '../../common/types/admin-role.enum';
|
||
|
|
|
||
|
|
@ApiTags('admin-content-safety')
|
||
|
|
@Controller('admin-api/content-safety')
|
||
|
|
@UseGuards(AdminAuthGuard, AdminRolesGuard)
|
||
|
|
@ApiBearerAuth()
|
||
|
|
export class ContentSafetyController {
|
||
|
|
constructor(private readonly svc: ContentSafetyService) {}
|
||
|
|
|
||
|
|
@Get('words') @AdminRoles('SUPER_ADMIN' as AdminRole) async words() { return this.svc.getAllWords() }
|
||
|
|
@Post('words') @AdminRoles('SUPER_ADMIN' as AdminRole) async addWord(@Body() d: { word: string; category: string; riskLevel: string }) { return this.svc.addWord(d.word, d.category, d.riskLevel) }
|
||
|
|
@Delete('words/:id') @AdminRoles('SUPER_ADMIN' as AdminRole) async removeWord(@Param('id') id: string) { await this.svc.removeWord(id); return { success: true } }
|
||
|
|
@Get('checks') @AdminRoles('SUPER_ADMIN' as AdminRole) async checks() { return this.svc.getChecks() }
|
||
|
|
}
|