24 lines
503 B
TypeScript
24 lines
503 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import { prisma } from '@/lib/prisma';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const locations = await prisma.location.findMany({
|
|
where: {
|
|
active: true,
|
|
},
|
|
orderBy: {
|
|
name: 'asc',
|
|
},
|
|
});
|
|
|
|
return NextResponse.json({ locations });
|
|
} catch (error) {
|
|
console.error('Locations fetch error:', error);
|
|
return NextResponse.json(
|
|
{ error: 'Internal server error' },
|
|
{ status: 500 }
|
|
);
|
|
}
|
|
}
|