feat(quest): add full CRUD and image handling for hunt quests
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
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
|
||||
})
|
||||
);
|
||||
|
||||
const quest = await prisma.huntQuest.findUnique({
|
||||
where: {
|
||||
id: questId,
|
||||
huntId,
|
||||
hunt: {
|
||||
members: {
|
||||
some: {
|
||||
memberId: userId
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
title_de: true,
|
||||
title_en: true,
|
||||
description_de: true,
|
||||
description_en: true,
|
||||
question_de: true,
|
||||
question_en: true,
|
||||
location: true,
|
||||
locationLink: true,
|
||||
order: true,
|
||||
optional: true,
|
||||
pictureRequired: true,
|
||||
textRequired: true,
|
||||
textType: true,
|
||||
textUnit: true,
|
||||
textSolution: true,
|
||||
points: true,
|
||||
extraPoints: true,
|
||||
extraText_de: true,
|
||||
extraText_en: true,
|
||||
picture: {
|
||||
select: {
|
||||
id: true,
|
||||
url: true
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (!quest) {
|
||||
throw createError({ statusCode: 404, statusMessage: 'Not found!' });
|
||||
}
|
||||
|
||||
return quest;
|
||||
});
|
||||
Reference in New Issue
Block a user