const express = require('express') const path = require('path') const app = express() app.use(express.json()) app.use(express.static('public')) app.use(express.urlencoded()) app.get("/", (req, res) => { res.sendFile(path.resolve('./index.html')) }) app.get('/ranking', async (req, res) => { const ranking = await (await fetch("https://www.nporadio2.nl/api/charts/npo-radio-2-top-2000-van-2025-12-25", {})).json(); res.send(ranking); }) app.get('/graph/:artist/:title', async (req, res) => { const artist = req.params.artist; const title = req.params.title; const data = await (await fetch(`https://nporadio2.nl/api/statistics/search/tracks/${artist}`, {})).json(); const id = data.find(it => it.title == title).id const standings = await (await fetch(`https://nporadio2.nl/api/statistics/positions/track/${id}`, {})).json(); res.send(standings); }) app.get('/trivia/:artist', async (req, res) => { const artist = req.params.artist; const data = await (await fetch(`https://nporadio2.nl/api/statistics/search/tracks/${artist}`, {})).json(); console.log(data); res.send(data); }) app.listen(5438, () => { console.log("Listening on port 5438") })