pollo/app/api/internal/room/[roomId]/votes/route.ts

27 lines
590 B
TypeScript
Raw Normal View History

2023-09-24 23:49:24 -06:00
import { NextResponse } from "next/server";
import { db } from "@/_lib/db";
import { votes } from "@/_lib/schema";
import { eq } from "drizzle-orm";
export async function GET(
request: Request,
{ params }: { params: { roomId: string } }
) {
if (!params.roomId) {
return new NextResponse("RoomId Missing!", {
status: 400,
statusText: "BAD REQUEST!",
});
}
2023-10-03 17:06:31 -06:00
const votesByRoomId = await db.query.votes.findMany({
where: eq(votes.roomId, params.roomId),
});
2023-09-24 23:49:24 -06:00
2023-10-03 17:06:31 -06:00
return NextResponse.json(votesByRoomId, {
status: 200,
statusText: "SUCCESS!",
});
2023-09-24 23:49:24 -06:00
}