posts "question of the day" to a discord webhook

Added global interfaces for type safety, filtering out empty questions

+12 -4
+2 -2
dev.ts
··· 52 52 const { themeName, theme } = getTheme(date); 53 53 54 54 const response = await fetch(endpoint); 55 - const data = await response.json(); 56 - const deck = data[themeName]; 55 + const data: QuestionsData = await response.json(); 56 + const deck = data[themeName].filter((item) => item.question.trim() !== ""); 57 57 58 58 let index: number; 59 59 if (args.index) {
+8
global.d.ts
··· 1 + interface QuestionItem { 2 + question: string; 3 + by: string; 4 + } 5 + 6 + interface QuestionsData { 7 + [key: string]: QuestionItem[]; 8 + }
+2 -2
main.ts
··· 15 15 16 16 // Fetch data 17 17 const response = await fetch(endpoint); 18 - const data = await response.json(); 19 - const deck = data[themeName]; 18 + const data: QuestionsData = await response.json(); 19 + const deck = data[themeName].filter((item) => item.question.trim() !== ""); 20 20 21 21 // Open KV and fetch last index 22 22 // @ts-ignore Deno.openKv is unstable, run with --unstable-kv flag