a new start

This commit is contained in:
valknarness
2025-10-25 16:09:02 +02:00
commit b63592f153
94 changed files with 23058 additions and 0 deletions

View File

@@ -0,0 +1,50 @@
import { NextRequest, NextResponse } from 'next/server'
import { getRepositoriesByList, getAwesomeLists } from '@/lib/db'
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params
const listId = parseInt(id, 10)
if (isNaN(listId)) {
return NextResponse.json(
{ error: 'Invalid list ID' },
{ status: 400 }
)
}
// Get the list info
const lists = getAwesomeLists()
const list = lists.find(l => l.id === listId)
if (!list) {
return NextResponse.json(
{ error: 'List not found' },
{ status: 404 }
)
}
// Parse pagination
const searchParams = request.nextUrl.searchParams
const page = parseInt(searchParams.get('page') || '1', 10)
const limit = parseInt(searchParams.get('limit') || '50', 10)
const offset = (page - 1) * limit
// Get repositories
const repositories = getRepositoriesByList(listId, limit, offset)
return NextResponse.json({
list,
repositories
})
} catch (error) {
console.error('List detail API error:', error)
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
)
}
}

24
app/api/lists/route.ts Normal file
View File

@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from 'next/server'
import { getAwesomeLists, getCategories } from '@/lib/db'
export async function GET(request: NextRequest) {
try {
const searchParams = request.nextUrl.searchParams
const category = searchParams.get('category') || undefined
const lists = getAwesomeLists(category)
const categories = getCategories()
return NextResponse.json({
lists,
categories,
total: lists.length
})
} catch (error) {
console.error('Lists API error:', error)
return NextResponse.json(
{ error: 'Internal server error' },
{ status: 500 }
)
}
}