Spaces:
Running
Running
Bibhu Mishra
fix: retrospective agent evaluated wrong month and crashed; persist its analysis to Reports tab
a381fc9 | import { | |
| Controller, | |
| Get, | |
| Param, | |
| Query, | |
| Res, | |
| UnauthorizedException, | |
| UseGuards, | |
| } from '@nestjs/common'; | |
| import { JwtService } from '@nestjs/jwt'; | |
| import type { Response } from 'express'; | |
| import { JwtAuthGuard } from '../auth/jwt-auth.guard'; | |
| import { streamPdf } from '../common/pdf-proxy.util'; | |
| import { ReportsService } from './reports.service'; | |
| ('reports') | |
| export class ReportsController { | |
| constructor( | |
| private svc: ReportsService, | |
| private jwt: JwtService, | |
| ) {} | |
| () | |
| (JwtAuthGuard) | |
| findAll() { | |
| return this.svc.findAll(); | |
| } | |
| (':id') | |
| (JwtAuthGuard) | |
| findOne(('id') id: string) { | |
| return this.svc.findOne(+id); | |
| } | |
| // Token verified manually from ?token= so a plain <a href> works without an | |
| // Authorization header. | |
| (':id/pdf') | |
| async pdf( | |
| ('id') id: string, | |
| ('token') token: string, | |
| () res: Response, | |
| ) { | |
| try { | |
| this.jwt.verify(token); | |
| } catch { | |
| throw new UnauthorizedException('Invalid or missing token'); | |
| } | |
| const pdfPath = await this.svc.getPdfPath(+id); | |
| await streamPdf(pdfPath, res); | |
| } | |
| } | |