Files
website/server/api/talents.get.ts
2024-04-20 00:03:10 +02:00

21 lines
517 B
TypeScript

export default defineEventHandler(async (event) => {
const { favorite, category } = getQuery(event)
const talents = await useDB().query.talents
.findMany({
orderBy: [asc(tables.talents.id)],
with: {
talentCategories: {
with: {
category: true
}
}
}
})
return talents.filter(talent =>
(category === 'all' || talent.talentCategories.some(cat => cat.category.slug === category))
&& (favorite === 'false' || talent.favorite)
)
})