import { Controller, Delete, Get, NotFoundException, Param, ParseIntPipe, Query } from '@nestjs/common'; import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger'; import { SessionService } from './session.service'; import { PaginationQueryDto } from '../common/dto/pagination.dto'; import { SessionOrderBy } from './session.service'; @ApiTags('sessions') @Controller('sessions') export class SessionController { constructor(private readonly sessionService: SessionService) {} @Get() @ApiOperation({ summary: 'List all stored sessions (paginated)' }) @ApiResponse({ status: 200, description: 'Paginated sessions' }) findAll(@Query() query: PaginationQueryDto) { return this.sessionService.findAll(query); } @Delete(':id') @ApiOperation({ summary: 'Delete a session by ID' }) @ApiResponse({ status: 200, description: 'Session deleted' }) @ApiResponse({ status: 404, description: 'Session not found' }) async remove(@Param('id', ParseIntPipe) id: number): Promise { const sessions = await this.sessionService.findAll(); if (!sessions.data.find(s => s.id === id)) { throw new NotFoundException(`Session ${id} not found`); } await this.sessionService.remove(id); } }