feat: BreakPilot PWA - Full codebase (clean push without large binaries)
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
Some checks failed
Tests / Go Tests (push) Has been cancelled
Tests / Python Tests (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / Go Lint (push) Has been cancelled
Tests / Python Lint (push) Has been cancelled
Tests / Security Scan (push) Has been cancelled
Tests / All Checks Passed (push) Has been cancelled
Security Scanning / Secret Scanning (push) Has been cancelled
Security Scanning / Dependency Vulnerability Scan (push) Has been cancelled
Security Scanning / Go Security Scan (push) Has been cancelled
Security Scanning / Python Security Scan (push) Has been cancelled
Security Scanning / Node.js Security Scan (push) Has been cancelled
Security Scanning / Docker Image Security (push) Has been cancelled
Security Scanning / Security Summary (push) Has been cancelled
CI/CD Pipeline / Go Tests (push) Has been cancelled
CI/CD Pipeline / Python Tests (push) Has been cancelled
CI/CD Pipeline / Website Tests (push) Has been cancelled
CI/CD Pipeline / Linting (push) Has been cancelled
CI/CD Pipeline / Security Scan (push) Has been cancelled
CI/CD Pipeline / Docker Build & Push (push) Has been cancelled
CI/CD Pipeline / Integration Tests (push) Has been cancelled
CI/CD Pipeline / Deploy to Staging (push) Has been cancelled
CI/CD Pipeline / Deploy to Production (push) Has been cancelled
CI/CD Pipeline / CI Summary (push) Has been cancelled
ci/woodpecker/manual/build-ci-image Pipeline was successful
ci/woodpecker/manual/main Pipeline failed
All services: admin-v2, studio-v2, website, ai-compliance-sdk, consent-service, klausur-service, voice-service, and infrastructure. Large PDFs and compiled binaries excluded via .gitignore.
This commit is contained in:
163
website/app/api/admin/uni-crawler/route.ts
Normal file
163
website/app/api/admin/uni-crawler/route.ts
Normal file
@@ -0,0 +1,163 @@
|
||||
/**
|
||||
* API Proxy for Uni-Crawler (edu-search-service Orchestrator)
|
||||
*
|
||||
* Proxies requests to the edu-search-service orchestrator API
|
||||
* so that the browser doesn't need direct access to the internal service
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
|
||||
// Use EDU_SEARCH_URL environment variable - internal Docker URL
|
||||
const EDU_SEARCH_URL = process.env.EDU_SEARCH_URL || 'http://localhost:8086'
|
||||
const EDU_SEARCH_API_KEY = process.env.EDU_SEARCH_API_KEY || 'dev-key'
|
||||
|
||||
// GET: Fetch status, queue, or universities
|
||||
export async function GET(request: NextRequest) {
|
||||
const searchParams = request.nextUrl.searchParams
|
||||
const action = searchParams.get('action')
|
||||
|
||||
try {
|
||||
let endpoint = ''
|
||||
let requiresAuth = true
|
||||
|
||||
switch (action) {
|
||||
case 'status':
|
||||
endpoint = '/v1/crawl/status'
|
||||
break
|
||||
case 'queue':
|
||||
endpoint = '/v1/crawl/queue'
|
||||
break
|
||||
case 'universities':
|
||||
endpoint = '/api/v1/universities'
|
||||
requiresAuth = false
|
||||
break
|
||||
default:
|
||||
return NextResponse.json({ error: 'Invalid action' }, { status: 400 })
|
||||
}
|
||||
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
if (requiresAuth) {
|
||||
headers['Authorization'] = `Bearer ${EDU_SEARCH_API_KEY}`
|
||||
}
|
||||
|
||||
const response = await fetch(`${EDU_SEARCH_URL}${endpoint}`, { headers })
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
return NextResponse.json(
|
||||
{ error: `Backend error: ${response.status}`, details: errorText },
|
||||
{ status: response.status }
|
||||
)
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return NextResponse.json(data)
|
||||
} catch (error) {
|
||||
console.error('uni-crawler API GET error:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to connect to edu-search-service' },
|
||||
{ status: 503 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// POST: Start/stop orchestrator, add to queue, etc.
|
||||
export async function POST(request: NextRequest) {
|
||||
const searchParams = request.nextUrl.searchParams
|
||||
const action = searchParams.get('action')
|
||||
|
||||
try {
|
||||
let endpoint = ''
|
||||
let method = 'POST'
|
||||
let body = null
|
||||
|
||||
switch (action) {
|
||||
case 'start':
|
||||
endpoint = '/v1/crawl/start'
|
||||
break
|
||||
case 'stop':
|
||||
endpoint = '/v1/crawl/stop'
|
||||
break
|
||||
case 'queue':
|
||||
endpoint = '/v1/crawl/queue'
|
||||
body = await request.json()
|
||||
break
|
||||
case 'pause':
|
||||
const pauseId = searchParams.get('university_id')
|
||||
endpoint = `/v1/crawl/queue/${pauseId}/pause`
|
||||
break
|
||||
case 'resume':
|
||||
const resumeId = searchParams.get('university_id')
|
||||
endpoint = `/v1/crawl/queue/${resumeId}/resume`
|
||||
break
|
||||
default:
|
||||
return NextResponse.json({ error: 'Invalid action' }, { status: 400 })
|
||||
}
|
||||
|
||||
const response = await fetch(`${EDU_SEARCH_URL}${endpoint}`, {
|
||||
method,
|
||||
headers: {
|
||||
'Authorization': `Bearer ${EDU_SEARCH_API_KEY}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
let errorData = { error: errorText }
|
||||
try {
|
||||
errorData = JSON.parse(errorText)
|
||||
} catch {}
|
||||
return NextResponse.json(errorData, { status: response.status })
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return NextResponse.json(data)
|
||||
} catch (error) {
|
||||
console.error('uni-crawler API POST error:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to connect to edu-search-service' },
|
||||
{ status: 503 }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// DELETE: Remove from queue
|
||||
export async function DELETE(request: NextRequest) {
|
||||
const searchParams = request.nextUrl.searchParams
|
||||
const universityId = searchParams.get('university_id')
|
||||
|
||||
if (!universityId) {
|
||||
return NextResponse.json({ error: 'university_id required' }, { status: 400 })
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch(`${EDU_SEARCH_URL}/v1/crawl/queue/${universityId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Authorization': `Bearer ${EDU_SEARCH_API_KEY}`,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text()
|
||||
return NextResponse.json(
|
||||
{ error: `Backend error: ${response.status}`, details: errorText },
|
||||
{ status: response.status }
|
||||
)
|
||||
}
|
||||
|
||||
const data = await response.json()
|
||||
return NextResponse.json(data)
|
||||
} catch (error) {
|
||||
console.error('uni-crawler API DELETE error:', error)
|
||||
return NextResponse.json(
|
||||
{ error: 'Failed to connect to edu-search-service' },
|
||||
{ status: 503 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user