jevstrudel.git / website / src / pages / jev / songs.json.js
1// The ids of the site's songs ("<theme>/<song>"), for the Worker: it counts
2// "do you agree with Jev?" votes only for songs this deploy has
3// (worker/src/votes.ts reads this file through its ASSETS binding, and from
4// the dev server in dev). One entry per songs/<theme>/<song>/SPEC.md, the
5// same glob the song index (jev/songs.mjs) builds from.
6const specs = import.meta.glob('../../../../songs/*/*/SPEC.md');
7
8const songIds = () =>
9  Object.keys(specs)
10    .map((path) => path.split('/songs/')[1].slice(0, -'/SPEC.md'.length))
11    .sort();
12
13export function GET() {
14  return new Response(JSON.stringify({ songs: songIds() }), { headers: { 'Content-Type': 'application/json' } });
15}