Skip to content

Commit 8246ab4

Browse files
[autofix.ci] apply automated fixes
1 parent d165cd2 commit 8246ab4

File tree

2 files changed

+417
-238
lines changed

2 files changed

+417
-238
lines changed

src/app/api/generate/route.ts

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
1-
import { NextRequest, NextResponse } from 'next/server';
2-
import { MultiStepReadmeGenerator } from '@/lib/multi-step-readme-generator';
1+
import { NextRequest, NextResponse } from "next/server";
2+
import { MultiStepReadmeGenerator } from "@/lib/multi-step-readme-generator";
33

4-
export const dynamic = 'force-dynamic';
4+
export const dynamic = "force-dynamic";
55

66
/**
77
* Enhanced Multi-Step README Generation Endpoint
8-
*
8+
*
99
* This endpoint uses a sophisticated multi-step approach to generate READMEs:
1010
* 1. Repository Analysis - Smart analysis with token-conscious filtering
1111
* 2. Section Planning - Dynamic sections based on project type
1212
* 3. Section Generation - Individual section generation within token limits
1313
* 4. Assembly & Validation - Retry logic and fallback mechanisms
14-
*
14+
*
1515
* Fixes token limit issues from issue #101 by generating sections individually.
1616
*/
1717
export async function POST(request: NextRequest) {
1818
try {
1919
const body = await request.json();
20-
const { url: githubUrl, language = 'English' } = body;
20+
const { url: githubUrl, language = "English" } = body;
2121

2222
// Validate required fields
2323
if (!githubUrl) {
2424
return NextResponse.json(
25-
{ error: 'GitHub URL is required' },
26-
{ status: 400 }
25+
{ error: "GitHub URL is required" },
26+
{ status: 400 },
2727
);
2828
}
2929

@@ -33,29 +33,29 @@ export async function POST(request: NextRequest) {
3333
parsedUrl = new URL(githubUrl.trim());
3434
} catch {
3535
return NextResponse.json(
36-
{ error: 'Please provide a valid URL' },
37-
{ status: 400 }
36+
{ error: "Please provide a valid URL" },
37+
{ status: 400 },
3838
);
3939
}
4040

4141
if (
42-
parsedUrl.hostname !== 'github.com' &&
43-
parsedUrl.hostname !== 'www.github.com'
42+
parsedUrl.hostname !== "github.com" &&
43+
parsedUrl.hostname !== "www.github.com"
4444
) {
4545
return NextResponse.json(
46-
{ error: 'Only GitHub URLs are supported' },
47-
{ status: 400 }
46+
{ error: "Only GitHub URLs are supported" },
47+
{ status: 400 },
4848
);
4949
}
5050

51-
const pathSegments = parsedUrl.pathname.split('/').filter(Boolean);
51+
const pathSegments = parsedUrl.pathname.split("/").filter(Boolean);
5252
const owner = pathSegments[0];
5353
const repo = pathSegments[1];
5454

5555
if (!owner || !repo) {
5656
return NextResponse.json(
57-
{ error: 'URL must include owner and repository name' },
58-
{ status: 400 }
57+
{ error: "URL must include owner and repository name" },
58+
{ status: 400 },
5959
);
6060
}
6161

@@ -69,13 +69,13 @@ export async function POST(request: NextRequest) {
6969
temperature: 0.7,
7070
concurrentSections: 3, // Generate multiple sections in parallel
7171
enableContinuation: true, // Enable automatic continuation for truncated content
72-
}
72+
},
7373
);
7474

7575
// Generate README with detailed tracking
7676
const startTime = Date.now();
7777
console.log(`Starting multi-step README generation for ${githubUrl}`);
78-
78+
7979
const result = await generator.generateReadme(githubUrl);
8080
const endTime = Date.now();
8181

@@ -90,14 +90,14 @@ export async function POST(request: NextRequest) {
9090
});
9191

9292
if (!result.success) {
93-
console.error('README generation failed:', result.errors);
93+
console.error("README generation failed:", result.errors);
9494
return NextResponse.json(
95-
{
96-
error: 'Failed to generate README using multi-step pipeline',
95+
{
96+
error: "Failed to generate README using multi-step pipeline",
9797
details: result.errors,
9898
stats: result.stats,
9999
},
100-
{ status: 500 }
100+
{ status: 500 },
101101
);
102102
}
103103

@@ -110,7 +110,7 @@ export async function POST(request: NextRequest) {
110110
sectionsTotal: result.stats.sectionsTotal,
111111
tokensUsed: result.stats.tokensUsed,
112112
timeElapsed: result.stats.timeElapsed,
113-
generationMethod: 'multi-step', // Indicate the method used
113+
generationMethod: "multi-step", // Indicate the method used
114114
},
115115
metadata: {
116116
name: result.metadata?.name,
@@ -124,15 +124,14 @@ export async function POST(request: NextRequest) {
124124
},
125125
warnings: result.errors.length > 0 ? result.errors : undefined,
126126
});
127-
128127
} catch (error) {
129-
console.error('Multi-step README generation API error:', error);
128+
console.error("Multi-step README generation API error:", error);
130129
return NextResponse.json(
131-
{
132-
error: 'Internal server error in multi-step README generation',
133-
message: error instanceof Error ? error.message : 'Unknown error'
130+
{
131+
error: "Internal server error in multi-step README generation",
132+
message: error instanceof Error ? error.message : "Unknown error",
134133
},
135-
{ status: 500 }
134+
{ status: 500 },
136135
);
137136
}
138-
}
137+
}

0 commit comments

Comments
 (0)