futher booking stuff
This commit is contained in:
32
apps/hub/app/api/stations/route.ts
Normal file
32
apps/hub/app/api/stations/route.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { prisma } from "@repo/db";
|
||||
import { getServerSession } from "../auth/[...nextauth]/auth";
|
||||
|
||||
// GET /api/station - Get all stations for booking selection
|
||||
export const GET = async () => {
|
||||
try {
|
||||
const session = await getServerSession();
|
||||
if (!session?.user) {
|
||||
return NextResponse.json({ error: "Not authenticated" }, { status: 401 });
|
||||
}
|
||||
|
||||
const stations = await prisma.station.findMany({
|
||||
select: {
|
||||
id: true,
|
||||
bosCallsign: true,
|
||||
bosCallsignShort: true,
|
||||
locationState: true,
|
||||
operator: true,
|
||||
aircraft: true,
|
||||
},
|
||||
orderBy: {
|
||||
bosCallsignShort: "asc",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json(stations);
|
||||
} catch (error) {
|
||||
console.error("Error fetching stations:", error);
|
||||
return NextResponse.json({ error: "Internal server error" }, { status: 500 });
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user