diff --git a/src/.index.mjs.kate-swp b/src/.index.mjs.kate-swp deleted file mode 100644 index 944bace..0000000 Binary files a/src/.index.mjs.kate-swp and /dev/null differ diff --git a/src/index.mjs b/src/index.mjs index fe3a498..b19c021 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -11,18 +11,15 @@ const server = createServer((req, res) => { req.on("data", chunk => (body += chunk)); req.on("end", async () => { - // 1️⃣ HTML parsen const $ = cheerio.load(body); const items = $(".item").map((i, el) => $(el).text()).get(); const results = []; - // 2️⃣ Redis abfragen (Set pro Item) for (const item of items) { const setMembers = await redis.sMembers(`item:${item}`); if (setMembers.length === 2) { - // Angenommen: [verkaufspreis, realwert] const [verkaufspreisStr, realwertStr] = setMembers; const verkaufspreis = parseInt(verkaufspreisStr, 10); const realwert = parseInt(realwertStr, 10); @@ -31,11 +28,9 @@ const server = createServer((req, res) => { } } - // 3️⃣ Sortieren & Top 5 const topVerkaufspreis = [...results].sort((a, b) => b.verkaufspreis - a.verkaufspreis).slice(0, 5); const topRealwert = [...results].sort((a, b) => b.realwert - a.realwert).slice(0, 5); - // 4️⃣ JSON-Antwort res.writeHead(200, { "Content-Type": "application/json" }); res.end(JSON.stringify({ topVerkaufspreis, topRealwert }, null, 2)); });