all rotations backend route

This commit is contained in:
Kalle (Sendou)
2020-12-15 18:43:32 +02:00
parent 25ffda52c4
commit dbb85bd969

18
pages/api/sr/rotations.ts Normal file
View File

@@ -0,0 +1,18 @@
import { NextApiRequest, NextApiResponse } from "next";
import prisma from "prisma/client";
const rotationsHandler = async (req: NextApiRequest, res: NextApiResponse) => {
if (req.method !== "GET") {
return res.status(405).end();
}
const rotations = await prisma.salmonRunRotation.findMany({
where: { startTime: { lt: new Date() } },
orderBy: { id: "desc" },
select: { id: true, startTime: true, weapons: true, stage: true },
});
res.status(200).json(rotations);
};
export default rotationsHandler;