You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
723 B
TypeScript
25 lines
723 B
TypeScript
1 month ago
|
import type { APIRoute, GetStaticPaths } from 'astro'
|
||
|
|
||
|
import database from '@/data/domande-esami.yaml'
|
||
|
|
||
|
export const getStaticPaths = (() => {
|
||
|
return Object.keys(database.names).map(course => ({
|
||
|
params: { course },
|
||
|
}))
|
||
|
}) satisfies GetStaticPaths
|
||
|
|
||
|
export const GET: APIRoute = ({ params: { course } }) => {
|
||
|
return new Response(
|
||
|
JSON.stringify({
|
||
|
groups: [],
|
||
|
names: Object.fromEntries(Object.entries(database.names).filter(([key]) => key === course)),
|
||
|
questions: database.questions.filter(question => question.course === course),
|
||
|
}),
|
||
|
{
|
||
|
headers: {
|
||
|
'content-type': 'application/json',
|
||
|
},
|
||
|
}
|
||
|
)
|
||
|
}
|