mirror of
https://github.com/yusufipk/RepoHub.git
synced 2026-09-11 18:46:07 +00:00
feat: add AUR repository support for Arch Linux packages
- Extended database schema and models to include 'aur' as a valid repository type alongside 'official' and 'third-party' - Added repository filter UI in package browser for Arch platform to distinguish between official and AUR packages - Enhanced init-db script with migration system to track and apply schema changes automatically
This commit is contained in:
@@ -11,7 +11,7 @@ export async function GET(request: NextRequest) {
|
||||
category_id: searchParams.get('category_id') ?
|
||||
parseInt(searchParams.get('category_id')!) : undefined,
|
||||
type: searchParams.get('type') as 'gui' | 'cli' | undefined,
|
||||
repository: searchParams.get('repository') as 'official' | 'third-party' | undefined,
|
||||
repository: searchParams.get('repository') as 'official' | 'third-party' | 'aur' | undefined,
|
||||
search: searchParams.get('search') || undefined,
|
||||
limit: searchParams.get('limit') ?
|
||||
parseInt(searchParams.get('limit')!) : undefined,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { SyncAuth } from '@/lib/sync/auth'
|
||||
import { AurPackageFetcher } from '@/services/aurPackageFetcher'
|
||||
|
||||
export const dynamic = 'force-dynamic'
|
||||
export const maxDuration = 300
|
||||
|
||||
let syncInProgress = false
|
||||
let syncStatus: {
|
||||
status: 'idle' | 'running' | 'complete' | 'error'
|
||||
error: string | null
|
||||
} = { status: 'idle', error: null }
|
||||
|
||||
export async function GET() {
|
||||
return NextResponse.json(syncStatus)
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const authResult = await SyncAuth.isSyncAllowed(request)
|
||||
if (!authResult.allowed) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Sync operation not allowed', reason: authResult.reason },
|
||||
{ status: 403 }
|
||||
)
|
||||
}
|
||||
|
||||
if (syncInProgress) {
|
||||
return NextResponse.json(
|
||||
{ error: 'Sync already in progress' },
|
||||
{ status: 409 }
|
||||
)
|
||||
}
|
||||
|
||||
syncInProgress = true
|
||||
syncStatus = { status: 'running', error: null }
|
||||
|
||||
;(async () => {
|
||||
try {
|
||||
const fetcher = new AurPackageFetcher()
|
||||
const pkgs = await fetcher.fetchAllPackages()
|
||||
await fetcher.storePackages(pkgs)
|
||||
syncStatus.status = 'complete'
|
||||
} catch (err: any) {
|
||||
syncStatus.status = 'error'
|
||||
syncStatus.error = err?.message || 'Unknown error'
|
||||
} finally {
|
||||
syncInProgress = false
|
||||
}
|
||||
})()
|
||||
|
||||
return NextResponse.json({ message: 'AUR sync started', status: syncStatus })
|
||||
}
|
||||
Reference in New Issue
Block a user