feat(api): something

This commit is contained in:
Isaac 2024-07-03 02:03:16 +01:00
parent 4d42269a35
commit b00d2f312e
No known key found for this signature in database
GPG Key ID: 0DE40AE37BBA5C33
2 changed files with 18 additions and 1 deletions

View File

@ -5,7 +5,6 @@ module.exports.get = fastify => ({
handler: async (req, res) => {
const { client } = req.routeOptions.config;
const guild = client.guilds.cache.get(req.params.guild);
if (!guild) return res.status(404).send(new Error('Not Found'));
res.send({
id: guild.id,
logo: iconURL(guild),

View File

@ -0,0 +1,18 @@
module.exports.get = fastify => ({
handler: async (req, res) => {
const { client } = req.routeOptions.config;
/** @type {import("@prisma/client").PrismaClient} */
const prisma = client.prisma;
const guild = client.guilds.cache.get(req.params.guild);
res.send(
await prisma.ticket.findMany({
where: {
createdById: req.user.id,
guildId: guild.id,
},
}),
);
},
onRequest: [fastify.authenticate, fastify.isMember],
});