feat(quest): add full CRUD and image handling for hunt quests

This commit is contained in:
2026-07-31 01:03:54 +02:00
parent 77becc453e
commit 24632742ef
15 changed files with 1228 additions and 7 deletions
@@ -0,0 +1,48 @@
import { useValidatedParams, z, zh } from 'h3-zod';
import prisma from '~~/lib/prisma';
export default defineEventHandler(async (event) => {
const user = await requireUserSession(event);
const userId = user.user.id;
const { huntId, questId } = await useValidatedParams(
event,
z.object({
huntId: zh.numAsString,
questId: zh.numAsString
})
);
// Verify membership
const quest = await prisma.huntQuest.findUnique({
where: {
id: questId,
huntId,
hunt: {
members: {
some: {
memberId: userId
}
}
}
},
select: {
id: true
}
});
if (!quest) {
throw createError({ statusCode: 404, statusMessage: 'Not found!' });
}
await prisma.huntQuest.update({
where: {
id: questId
},
data: {
pictureId: null
}
});
return { success: true };
});