clip / apps /backend /src /admin /admin.controller.ts
Husr's picture
first commit
d988ae4
import { Body, Controller, Delete, Get, Param, Post, UseGuards } from '@nestjs/common';
import { AdminService } from './admin.service';
import { AdminAuthGuard } from './admin.guard';
@Controller('admin')
@UseGuards(AdminAuthGuard)
export class AdminController {
constructor(private readonly adminService: AdminService) { }
@Get('clipboards')
listClipboards() {
return this.adminService.listClipboards();
}
@Get('clipboards/:roomCode')
getClipboard(@Param('roomCode') roomCode: string) {
return this.adminService.getClipboard(roomCode);
}
@Post('clipboards/:roomCode/password')
updatePassword(
@Param('roomCode') roomCode: string,
@Body() body: { password?: string | null },
) {
return this.adminService.setPassword(roomCode, body.password);
}
@Post('clipboards/:roomCode/ttl')
updateTTL(
@Param('roomCode') roomCode: string,
@Body() body: { ttl?: number | null },
) {
const ttl = body.ttl === null || body.ttl === undefined ? null : Number(body.ttl);
return this.adminService.setTTL(roomCode, isNaN(ttl) ? null : ttl);
}
@Delete('clipboards/:roomCode')
deleteClipboard(@Param('roomCode') roomCode: string) {
return this.adminService.deleteClipboard(roomCode);
}
}