Skip to content

Commit 2a8cc85

Browse files
committed
Implement cache and status APIs with GET handlers for stats, clear, and health actions
1 parent ca6304f commit 2a8cc85

3 files changed

Lines changed: 57 additions & 0 deletions

File tree

app/api/cache/route.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { NextRequest, NextResponse } from 'next/server';
2+
import { getCacheStats, clearInMemoryCache } from '@/lib/cache';
3+
export async function GET(request: NextRequest) {
4+
const { searchParams } = new URL(request.url);
5+
const action = searchParams.get('action');
6+
7+
try {
8+
switch (action) {
9+
case 'stats':
10+
const stats = getCacheStats();
11+
return NextResponse.json(stats);
12+
13+
case 'clear':
14+
clearInMemoryCache();
15+
return NextResponse.json({ message: 'In-memory cache cleared successfully' });
16+
17+
default:
18+
return NextResponse.json({
19+
message: 'Cache API',
20+
availableActions: [
21+
'stats - Get cache statistics',
22+
'clear - Clear in-memory cache',
23+
'revalidate - Revalidate GitHub API cache'
24+
]
25+
});
26+
}
27+
} catch (error) {
28+
console.error('Cache API error:', error);
29+
return NextResponse.json(
30+
{ error: 'Internal server error' },
31+
{ status: 500 }
32+
);
33+
}
34+
}
35+
36+
export async function generateStaticParams() {
37+
return [];
38+
}

app/api/search/route.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//import { useDocsSearch } from 'fumadocs-core/search/client';
2+
//import { create } from '@orama/orama';
3+
import { NextRequest, NextResponse } from "next/server";
4+
//import { createFromSource } from 'fumadocs-core/search/server';
5+
//import { source } from '@/lib/source';
6+
//import { createLocalSource } from "@/lib/sources/local";
7+
8+
export async function GET() {
9+
return NextResponse.json({ message: "Search not implemented" });
10+
}
11+
12+
export async function generateStaticParams() {
13+
return [];
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ export async function GET(request: NextRequest) {
3030
});
3131
}
3232
}
33+
34+
35+
export async function generateStaticParams() {
36+
return [];
37+
}

0 commit comments

Comments
 (0)