mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-04-22 15:09:16 -05:00
closes #254 fa bot api
This commit is contained in:
parent
7241401680
commit
1cc306db55
40
pages/api/bot/freeagents.ts
Normal file
40
pages/api/bot/freeagents.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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;
|
||||
Loading…
Reference in New Issue
Block a user