Skip to content

Commit b46f691

Browse files
⚡ optimize docs-tree API and fix CI lint errors
- Refactor `app/api/docs-tree/route.ts` to use asynchronous I/O and parallel processing. - Fix ESLint `prefer-const` errors in `app/api/docs-tree/route.ts`. - Remove unused `GitHub` import in `auth.config.ts`. - Fix unused `error` variable in `scripts/check-pnpm-version.mjs`. Co-authored-by: longsizhuo <114939201+longsizhuo@users.noreply.github.com>
1 parent b9c98fa commit b46f691

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

app/api/docs-tree/route.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ export async function GET() {
110110
}
111111

112112
// pick the first existing candidate
113-
let docsRoot: string | undefined;
114113
const candidateChecks = await Promise.all(
115114
candidates.map(async (p) => {
116115
try {
@@ -121,7 +120,7 @@ export async function GET() {
121120
}
122121
}),
123122
);
124-
docsRoot = candidateChecks.find((c) => c.exists)?.p;
123+
const docsRoot = candidateChecks.find((c) => c.exists)?.p;
125124

126125
if (!docsRoot) {
127126
return NextResponse.json(
@@ -140,9 +139,9 @@ export async function GET() {
140139
}
141140

142141
// try to list
143-
let tree: DirNode[] = [];
144142
try {
145-
tree = await buildTree(docsRoot, 2);
143+
const tree = await buildTree(docsRoot, 2);
144+
return NextResponse.json({ ok: true, docsRoot, tree, diag });
146145
} catch (e: unknown) {
147146
const msg = e instanceof Error ? e.message : String(e);
148147
return NextResponse.json(
@@ -155,8 +154,6 @@ export async function GET() {
155154
{ status: 500 },
156155
);
157156
}
158-
159-
return NextResponse.json({ ok: true, docsRoot, tree, diag });
160157
} catch (err: unknown) {
161158
const msg = err instanceof Error ? err.message : String(err);
162159
return NextResponse.json(

auth.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { NextAuthConfig } from "next-auth";
2-
import GitHub from "next-auth/providers/github";
32

43
// 在本地开发环境允许没有 .env 的协作者运行站点,因此先尝试读取两个常见的密钥变量,缺失时再使用内置的开发兜底值。
54
const envSecret = process.env.AUTH_SECRET ?? process.env.NEXTAUTH_SECRET;

scripts/check-pnpm-version.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ try {
5454
let actualVersion;
5555
try {
5656
actualVersion = execSync('pnpm --version', { encoding: 'utf-8' }).trim();
57-
} catch (error) {
57+
} catch {
5858
console.error('❌ Error: pnpm is not installed or not found in PATH');
5959
console.error('\nTo fix this issue:');
6060
console.error('1. Enable corepack: corepack enable');

0 commit comments

Comments
 (0)