phase-10.5: screener enhancements
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import type { FastifyInstance, FastifyRequest } from 'fastify';
|
||||
import { DigestService } from './DigestService';
|
||||
|
||||
/**
|
||||
* On-demand digest read (P1.1). The scheduled path is bin/daily-digest.ts;
|
||||
* this endpoint lets the UI (or curl) build the same report any time.
|
||||
*/
|
||||
export class DigestController {
|
||||
constructor(private readonly digest: DigestService) {}
|
||||
|
||||
register(app: FastifyInstance): void {
|
||||
app.get('/api/digest', this.today.bind(this));
|
||||
}
|
||||
|
||||
/** GET /api/digest?date=YYYY-MM-DD (defaults to today) */
|
||||
private async today(req: FastifyRequest) {
|
||||
const { date } = req.query as { date?: string };
|
||||
const day =
|
||||
date && /^\d{4}-\d{2}-\d{2}$/.test(date) ? date : new Date().toISOString().slice(0, 10);
|
||||
return this.digest.build(day);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user