feat: add PostgreSQL database support and development scripts

- Added pg and @types/pg dependencies for PostgreSQL integration
- Created database testing and backend initialization scripts
- Changed dev server port to 3002 to avoid conflicts
This commit is contained in:
Yusuf İpek
2025-11-10 18:02:08 +03:00
parent e82366e5e8
commit 596bba0832
17 changed files with 1518 additions and 3 deletions
+53
View File
@@ -0,0 +1,53 @@
import { NextRequest, NextResponse } from 'next/server'
import { MetadataFetcher } from '@/services/metadataFetcher'
export async function POST(request: NextRequest) {
try {
const body = await request.json()
const { platform_id, all_platforms } = body
if (all_platforms) {
// Sync all platforms
await MetadataFetcher.syncAllPlatforms()
return NextResponse.json({
message: 'All platforms synced successfully',
timestamp: new Date().toISOString()
})
} else if (platform_id) {
// Sync specific platform
await MetadataFetcher.syncPlatform(platform_id)
return NextResponse.json({
message: `Platform ${platform_id} synced successfully`,
timestamp: new Date().toISOString()
})
} else {
return NextResponse.json(
{ error: 'Either platform_id or all_platforms must be specified' },
{ status: 400 }
)
}
} catch (error) {
console.error('Error during sync:', error)
return NextResponse.json(
{ error: 'Sync failed', details: error instanceof Error ? error.message : 'Unknown error' },
{ status: 500 }
)
}
}
export async function GET() {
try {
// Return sync status (would need to implement status tracking)
return NextResponse.json({
status: 'ready',
last_sync: null,
platforms: ['ubuntu', 'fedora', 'arch', 'windows', 'macos']
})
} catch (error) {
console.error('Error getting sync status:', error)
return NextResponse.json(
{ error: 'Failed to get sync status' },
{ status: 500 }
)
}
}