MCPcopy Create free account
hub / github.com/BingyanStudio/github-analyzer / generateReport

Function generateReport

api/src/services/generateReport.ts:500–702  ·  view source on GitHub ↗
(req: BunRequest)

Source from the content-addressed store, hash-verified

498}
499
500export async function generateReport(req: BunRequest) {
501 const sessionId = req.cookies.get("session");
502 if (sessionId === null) {
503 return Response.json(
504 {
505 state: "Failed",
506 message: "Invalid session ID.",
507 },
508 {
509 status: 401,
510 }
511 );
512 }
513 const session = await sessionStore.getSession(sessionId);
514 if (session === null) {
515 return Response.json(
516 {
517 state: "Failed",
518 message: "Invalid session ID.",
519 },
520 {
521 status: 401,
522 }
523 );
524 }
525
526 // Get preset key from URL search params
527 const url = new URL(req.url);
528 const presetKey = url.searchParams.get("preset") || "man_page";
529 const forceRegen = url.searchParams.get("force_regen") === "true";
530
531 if (!presets[presetKey]) {
532 return Response.json(
533 {
534 state: "Failed",
535 message: `Preset '${presetKey}' not found.`,
536 },
537 {
538 status: 400,
539 }
540 );
541 }
542
543 // Generate a unique key for this report that includes the preset
544 const reportKey = generateReportKey(session?.login, presetKey);
545
546 // Set up Server-Sent Events response
547 const stream = new ReadableStream({
548 start(controller) {
549 // Helper function to send SSE events
550 const sendEvent = (eventType: string, data: any) => {
551 controller.enqueue(
552 `event: ${eventType}\ndata: ${JSON.stringify(data)}\n\n`
553 );
554 };
555
556 // Self-invoking async function to handle the report generation process
557 (async () => {

Callers

nothing calls this directly

Calls 2

generateReportKeyFunction · 0.85
getSessionMethod · 0.45

Tested by

no test coverage detected