mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-09 04:02:40 -05:00
41 lines
928 B
TypeScript
41 lines
928 B
TypeScript
import { NextApiRequest, NextApiResponse } from "next";
|
|
import prisma from "prisma/client";
|
|
|
|
const teamsFreeAgentsHandler = async (
|
|
req: NextApiRequest,
|
|
res: NextApiResponse
|
|
) => {
|
|
if (req.method !== "GET") {
|
|
return res.status(405).end();
|
|
}
|
|
|
|
const dateMonthAgo = new Date();
|
|
dateMonthAgo.setMonth(dateMonthAgo.getMonth() - 1);
|
|
|
|
const freeAgents = await prisma.freeAgentPost.findMany({
|
|
select: {
|
|
canVC: true,
|
|
content: true,
|
|
playstyles: true,
|
|
updatedAt: true,
|
|
user: {
|
|
select: {
|
|
discordId: true,
|
|
discordAvatar: true,
|
|
username: true,
|
|
discriminator: true,
|
|
profile: { select: { country: true, weaponPool: true } },
|
|
},
|
|
},
|
|
},
|
|
where: { updatedAt: { gte: dateMonthAgo } },
|
|
orderBy: {
|
|
updatedAt: "desc",
|
|
},
|
|
});
|
|
|
|
res.status(200).json(freeAgents);
|
|
};
|
|
|
|
export default teamsFreeAgentsHandler;
|