Разработка интерфейса фронт
This commit is contained in:
28
frontend/app/api/get-detectors-data/route.ts
Normal file
28
frontend/app/api/get-detectors-data/route.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { readFile } from 'fs/promises'
|
||||
import { join } from 'path'
|
||||
|
||||
export async function GET() {
|
||||
try {
|
||||
// Имитация полученных данных в формате json (данные в data/detectors.json)
|
||||
const filePath = join(process.cwd(), 'frontend', 'data', 'detectors.json')
|
||||
const fileContent = await readFile(filePath, 'utf8')
|
||||
const allData = JSON.parse(fileContent)
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
data: allData,
|
||||
objectsCount: Object.keys(allData.objects || {}).length,
|
||||
detectorsCount: Object.keys(allData.detectors || {}).length
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('Error fetching detectors data:', error)
|
||||
return NextResponse.json(
|
||||
{
|
||||
success: false,
|
||||
error: 'Failed to fetch detectors data'
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user