Skip to content

Commit 9b50be9

Browse files
committed
update for flashcards v2
1 parent eb905f7 commit 9b50be9

File tree

4 files changed

+275
-15
lines changed

4 files changed

+275
-15
lines changed

flashcards/cardSetsDataV2.json

Lines changed: 258 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
{
2+
"collection": [
3+
{
4+
"id": "01925ed0-c686-7dc8-87af-41faeb114c0f",
5+
"name": "Spanish",
6+
"flashcards": {
7+
"01925ed0-c681-7e3e-acb7-9775fbd1086f": {
8+
"id": "01925ed0-c681-7e3e-acb7-9775fbd1086f",
9+
"front": "Hola, ¿cómo estás?",
10+
"back": "Hello, how are you?",
11+
"history": { "frontResults": [], "backResults": [] }
12+
},
13+
"01925ed0-c683-7ddf-bccc-d013308bc068": {
14+
"id": "01925ed0-c683-7ddf-bccc-d013308bc068",
15+
"front": "Bien, gracias",
16+
"back": "Fine, thank you",
17+
"history": { "frontResults": [], "backResults": [] }
18+
},
19+
"01925ed0-c683-7a89-9c22-85f3afba93b7": {
20+
"id": "01925ed0-c683-7a89-9c22-85f3afba93b7",
21+
"front": "¿Cómo te llamas?",
22+
"back": "What's your name?",
23+
"history": { "frontResults": [], "backResults": [] }
24+
},
25+
"01925ed0-c683-7afc-87bb-1f4f4db2cf47": {
26+
"id": "01925ed0-c683-7afc-87bb-1f4f4db2cf47",
27+
"front": "Adiós",
28+
"back": "Goodbye",
29+
"history": { "frontResults": [], "backResults": [] }
30+
},
31+
"01925ed0-c683-7608-8dbd-a2aff862640d": {
32+
"id": "01925ed0-c683-7608-8dbd-a2aff862640d",
33+
"front": "Me llamo Juan",
34+
"back": "My name is Juan",
35+
"history": { "frontResults": [], "backResults": [] }
36+
},
37+
"01925ed0-c683-74d4-a320-2f513991ddcd": {
38+
"id": "01925ed0-c683-74d4-a320-2f513991ddcd",
39+
"front": "Buenas noches",
40+
"back": "Good evening",
41+
"history": { "frontResults": [], "backResults": [] }
42+
},
43+
"01925ed0-c683-7fa4-ba54-2a68032d0249": {
44+
"id": "01925ed0-c683-7fa4-ba54-2a68032d0249",
45+
"front": "Los árboles hablan cuando no miramos",
46+
"back": "Trees talk when we aren't looking",
47+
"history": { "frontResults": [], "backResults": [] }
48+
}
49+
},
50+
"cardStatusMap": {
51+
"cardStatusMap": {
52+
"CardStatus.notPresented": [],
53+
"CardStatus.newCards": [],
54+
"CardStatus.oneTime": [],
55+
"CardStatus.twoTimes": [],
56+
"CardStatus.occasional": [],
57+
"CardStatus.errorCorrection": []
58+
}
59+
}
60+
},
61+
{
62+
"id": "01925ed0-c686-727e-af24-d558b13e766d",
63+
"name": "French",
64+
"flashcards": {
65+
"01925ed0-c685-73be-b39f-b5ec1c0dd579": {
66+
"id": "01925ed0-c685-73be-b39f-b5ec1c0dd579",
67+
"front": "J'ai mal à la tête",
68+
"back": "My head hurts",
69+
"history": { "frontResults": [], "backResults": [] }
70+
},
71+
"01925ed0-c685-7878-b84f-107837eaa6ee": {
72+
"id": "01925ed0-c685-7878-b84f-107837eaa6ee",
73+
"front": "Il a les yeux bleus",
74+
"back": "He has blue eyes",
75+
"history": { "frontResults": [], "backResults": [] }
76+
},
77+
"01925ed0-c685-7c15-8c54-90bdb5ca38ba": {
78+
"id": "01925ed0-c685-7c15-8c54-90bdb5ca38ba",
79+
"front": "Je me brosse les dents chaque jour",
80+
"back": "I brush my teeth every day",
81+
"history": { "frontResults": [], "backResults": [] }
82+
},
83+
"01925ed0-c685-7a21-af3b-7b492a178d0f": {
84+
"id": "01925ed0-c685-7a21-af3b-7b492a178d0f",
85+
"front": "Les mains sont sales",
86+
"back": "The hands are dirty",
87+
"history": { "frontResults": [], "backResults": [] }
88+
},
89+
"01925ed0-c685-7276-9a08-ee0bdc371fe0": {
90+
"id": "01925ed0-c685-7276-9a08-ee0bdc371fe0",
91+
"front": "Elle a les cheveux longs et bouclés",
92+
"back": "\"She has long",
93+
"history": { "frontResults": [], "backResults": [] }
94+
},
95+
"01925ed0-c685-7a99-81a0-839776d5a38a": {
96+
"id": "01925ed0-c685-7a99-81a0-839776d5a38a",
97+
"front": "Je me suis blessé le pied en jouant au football",
98+
"back": "I hurt my foot playing soccer",
99+
"history": { "frontResults": [], "backResults": [] }
100+
},
101+
"01925ed0-c685-722a-b50f-406ba8f6e2e8": {
102+
"id": "01925ed0-c685-722a-b50f-406ba8f6e2e8",
103+
"front": "Les enfants se lavent le visage",
104+
"back": "The children wash their faces",
105+
"history": { "frontResults": [], "backResults": [] }
106+
},
107+
"01925ed0-c685-7353-85ac-da7f0f16a3bd": {
108+
"id": "01925ed0-c685-7353-85ac-da7f0f16a3bd",
109+
"front": "J'ai une cicatrice sur le genou",
110+
"back": "I have a scar on my knee",
111+
"history": { "frontResults": [], "backResults": [] }
112+
},
113+
"01925ed0-c685-7756-93e6-5de24b960102": {
114+
"id": "01925ed0-c685-7756-93e6-5de24b960102",
115+
"front": "Je me suis coupé le doigt en cuisinant",
116+
"back": "I cut my finger while cooking",
117+
"history": { "frontResults": [], "backResults": [] }
118+
},
119+
"01925ed0-c685-7229-aae9-fc45219c2178": {
120+
"id": "01925ed0-c685-7229-aae9-fc45219c2178",
121+
"front": "Le cœur bat vite",
122+
"back": "The heart beats fast",
123+
"history": { "frontResults": [], "backResults": [] }
124+
},
125+
"01925ed0-c685-726a-83c9-a1e59eaa8cf5": {
126+
"id": "01925ed0-c685-726a-83c9-a1e59eaa8cf5",
127+
"front": "Les oreilles servent à entendre",
128+
"back": "Ears are used for hearing",
129+
"history": { "frontResults": [], "backResults": [] }
130+
},
131+
"01925ed0-c685-7f27-8782-8bdbbc750547": {
132+
"id": "01925ed0-c685-7f27-8782-8bdbbc750547",
133+
"front": "Elle a mis une bague à son doigt",
134+
"back": "She put a ring on her finger",
135+
"history": { "frontResults": [], "backResults": [] }
136+
},
137+
"01925ed0-c685-7936-934e-c394f2e01137": {
138+
"id": "01925ed0-c685-7936-934e-c394f2e01137",
139+
"front": "J'ai besoin de reposer mon dos",
140+
"back": "I need to rest my back",
141+
"history": { "frontResults": [], "backResults": [] }
142+
},
143+
"01925ed0-c685-7c4b-8565-10e286a5cd6e": {
144+
"id": "01925ed0-c685-7c4b-8565-10e286a5cd6e",
145+
"front": "Il a une barbe sur le menton",
146+
"back": "He has a beard on his chin",
147+
"history": { "frontResults": [], "backResults": [] }
148+
},
149+
"01925ed0-c685-71e3-90f5-d27e7db239ed": {
150+
"id": "01925ed0-c685-71e3-90f5-d27e7db239ed",
151+
"front": "Mes muscles me font mal après avoir couru",
152+
"back": "My muscles hurt after running",
153+
"history": { "frontResults": [], "backResults": [] }
154+
},
155+
"01925ed0-c685-71c7-b8e4-96dd3a8738f4": {
156+
"id": "01925ed0-c685-71c7-b8e4-96dd3a8738f4",
157+
"front": "Les poumons aident à respirer",
158+
"back": "The lungs help us breathe",
159+
"history": { "frontResults": [], "backResults": [] }
160+
},
161+
"01925ed0-c685-7998-9609-2d0b19f741de": {
162+
"id": "01925ed0-c685-7998-9609-2d0b19f741de",
163+
"front": "Elle s'est peint les ongles",
164+
"back": "She painted her nails",
165+
"history": { "frontResults": [], "backResults": [] }
166+
},
167+
"01925ed0-c685-76a3-9440-980a32df286b": {
168+
"id": "01925ed0-c685-76a3-9440-980a32df286b",
169+
"front": "Je me suis foulé la cheville en jouant au basket",
170+
"back": "I sprained my ankle playing basketball",
171+
"history": { "frontResults": [], "backResults": [] }
172+
},
173+
"01925ed0-c685-77c6-9211-d0e262a378cc": {
174+
"id": "01925ed0-c685-77c6-9211-d0e262a378cc",
175+
"front": "Les sourcils donnent de l'expression au visage",
176+
"back": "Eyebrows give expression to the face",
177+
"history": { "frontResults": [], "backResults": [] }
178+
},
179+
"01925ed0-c685-7fc9-9fb6-ffef340b3812": {
180+
"id": "01925ed0-c685-7fc9-9fb6-ffef340b3812",
181+
"front": "Il a de larges épaules",
182+
"back": "He has broad shoulders",
183+
"history": { "frontResults": [], "backResults": [] }
184+
},
185+
"01925ed0-c685-7784-ad87-bace1f357130": {
186+
"id": "01925ed0-c685-7784-ad87-bace1f357130",
187+
"front": "L'estomac est vide",
188+
"back": "The stomach is empty",
189+
"history": { "frontResults": [], "backResults": [] }
190+
},
191+
"01925ed0-c685-7d87-b081-44deaed05a3f": {
192+
"id": "01925ed0-c685-7d87-b081-44deaed05a3f",
193+
"front": "Les jambes sont fatiguées",
194+
"back": "The legs are tired",
195+
"history": { "frontResults": [], "backResults": [] }
196+
},
197+
"01925ed0-c685-7e83-8ebc-8751b8c5e130": {
198+
"id": "01925ed0-c685-7e83-8ebc-8751b8c5e130",
199+
"front": "Le cou soutient la tête",
200+
"back": "The neck supports the head",
201+
"history": { "frontResults": [], "backResults": [] }
202+
},
203+
"01925ed0-c685-7d77-969d-3d385f5c33db": {
204+
"id": "01925ed0-c685-7d77-969d-3d385f5c33db",
205+
"front": "Je me suis brûlé la langue avec le café chaud",
206+
"back": "I burned my tongue with hot coffee",
207+
"history": { "frontResults": [], "backResults": [] }
208+
},
209+
"01925ed0-c685-7109-a61d-0dc6012c1851": {
210+
"id": "01925ed0-c685-7109-a61d-0dc6012c1851",
211+
"front": "Les lèvres sont sèches",
212+
"back": "The lips are dry",
213+
"history": { "frontResults": [], "backResults": [] }
214+
},
215+
"01925ed0-c685-702c-b495-6596fedf816f": {
216+
"id": "01925ed0-c685-702c-b495-6596fedf816f",
217+
"front": "J'ai besoin d'étirer mes bras",
218+
"back": "I need to stretch my arms",
219+
"history": { "frontResults": [], "backResults": [] }
220+
},
221+
"01925ed0-c685-7a4e-9f59-501999cce72f": {
222+
"id": "01925ed0-c685-7a4e-9f59-501999cce72f",
223+
"front": "Le cerveau est un organe complexe",
224+
"back": "The brain is a complex organ",
225+
"history": { "frontResults": [], "backResults": [] }
226+
},
227+
"01925ed0-c685-7066-a3dc-a6d9a1bfc98a": {
228+
"id": "01925ed0-c685-7066-a3dc-a6d9a1bfc98a",
229+
"front": "Je me suis cogné le front contre la porte",
230+
"back": "I hit my forehead on the door",
231+
"history": { "frontResults": [], "backResults": [] }
232+
},
233+
"01925ed0-c685-7142-928f-5851b6b7e473": {
234+
"id": "01925ed0-c685-7142-928f-5851b6b7e473",
235+
"front": "Elle a de longs cils",
236+
"back": "She has long eyelashes",
237+
"history": { "frontResults": [], "backResults": [] }
238+
},
239+
"01925ed0-c685-7892-9b74-37dd0356add0": {
240+
"id": "01925ed0-c685-7892-9b74-37dd0356add0",
241+
"front": "Mes genoux me font mal en montant les escaliers",
242+
"back": "My knees hurt when climbing stairs",
243+
"history": { "frontResults": [], "backResults": [] }
244+
}
245+
},
246+
"cardStatusMap": {
247+
"cardStatusMap": {
248+
"CardStatus.notPresented": [],
249+
"CardStatus.newCards": [],
250+
"CardStatus.oneTime": [],
251+
"CardStatus.twoTimes": [],
252+
"CardStatus.occasional": [],
253+
"CardStatus.errorCorrection": []
254+
}
255+
}
256+
}
257+
]
258+
}

flashcards/flashcards.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
import { promises as fs } from "fs";
22

3-
async function getFlashcards() {
3+
async function getFlashcards(version) {
4+
let fileNameString = "";
5+
switch (version) {
6+
case "v1":
7+
fileNameString = "flashcards/cardSetsDataV1.json";
8+
case "v2":
9+
fileNameString = "flashcards/cardSetsDataV2.json";
10+
default:
11+
console.log("Invalid version");
12+
}
413
// load the cardsets from the json file
514
try {
6-
const cardSetsData = await fs.readFile("flashcards/cardSetsData.json", {
15+
const cardSetsData = await fs.readFile(fileNameString, {
716
encoding: "utf8",
817
});
918
console.log(cardSetsData);

server.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,11 @@ app.post("/mega-search", async (req, res) => {
3030
});
3131

3232
app.post("/flashcards/v2", async (req, res) => {
33-
const clientCode = req.body.code;
34-
console.log(clientCode);
35-
if (clientCode === "g") {
36-
const responseData = {
37-
message: "Access code accepted",
38-
cardSets: await getFlashcards(),
39-
};
40-
// console.log(responseData);
41-
res.json(responseData);
42-
} else {
43-
res.status(401).send("Unauthorized");
44-
}
33+
const responseData = {
34+
message: "v2 flashcards",
35+
cardSets: await getFlashcards("v2"),
36+
};
37+
res.json(responseData);
4538
});
4639

4740
app.post("/flashcards/v1", async (req, res) => {
@@ -50,7 +43,7 @@ app.post("/flashcards/v1", async (req, res) => {
5043
if (clientCode === "g") {
5144
const responseData = {
5245
message: "Access code accepted",
53-
cardSets: await getFlashcards(),
46+
cardSets: await getFlashcards("v1"),
5447
};
5548
// console.log(responseData);
5649
res.json(responseData);

0 commit comments

Comments
 (0)