2024-11-24 18:44:19 -06:00

23 lines
580 B
TypeScript

import { NextResponse } from 'next/server'
import { prisma } from '@/lib/prisma'
export async function GET(
request: Request,
{ params }: { params: { cid: string } }
) {
try {
const sessions = await prisma.controllerSession.findMany({
where: {
cid: params.cid,
},
orderBy: {
lastSeen: 'desc',
},
})
return NextResponse.json(sessions)
} catch (error) {
console.error('Failed to fetch controller sessions:', error)
return NextResponse.json({ error: 'Failed to fetch controller sessions' }, { status: 500 })
}
}