added heliport layer
This commit is contained in:
22
apps/dispatch/app/api/heliports/route.ts
Normal file
22
apps/dispatch/app/api/heliports/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { prisma } from "@repo/db";
|
||||
|
||||
export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const id = searchParams.get("id");
|
||||
const filter = searchParams.get("filter");
|
||||
|
||||
try {
|
||||
const data = await prisma.heliport.findMany({
|
||||
where: {
|
||||
id: id ? Number(id) : undefined,
|
||||
...(filter ? JSON.parse(filter) : {}),
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(data, { status: 200 });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return NextResponse.json({ error: "Failed to fetch heliport" }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user