commit 9576e9cf44dcdc2407d5edd6616ee78db78afaae Author: Lukas Cremer Date: Sat May 16 15:57:49 2026 +0200 init commit diff --git a/package.json b/package.json new file mode 100644 index 0000000..68fee86 --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "bond-sniffer", + "version": "0.1.0", + "type": "module", + "scripts": { + "start": "node server.js" + } +} diff --git a/server.js b/server.js new file mode 100644 index 0000000..cb1b802 --- /dev/null +++ b/server.js @@ -0,0 +1,65 @@ +import http from 'http'; +import https from 'https'; +import fs from 'fs'; +import path from 'path'; +import { fileURLToPath } from 'url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const PORT = 3000; + +const MIME = { + '.html': 'text/html', + '.js': 'application/javascript', + '.css': 'text/css', + '.json': 'application/json', +}; + +function proxyOnvista(req, res) { + const url = new URL(req.url, `http://localhost:${PORT}`); + + // Forward all query params as-is to onvista + const upstream = `https://api.onvista.de/api/v1/bonds/finder/configuration_query?${url.searchParams.toString()}`; + + const options = { + headers: { + 'User-Agent': 'Mozilla/5.0', + 'Accept': 'application/json', + } + }; + + https.get(upstream, options, upRes => { + let body = ''; + upRes.on('data', chunk => body += chunk); + upRes.on('end', () => { + res.writeHead(upRes.statusCode, { + 'Content-Type': 'application/json', + 'Access-Control-Allow-Origin': '*', + }); + res.end(body); + }); + }).on('error', err => { + res.writeHead(502, { 'Content-Type': 'application/json' }); + res.end(JSON.stringify({ error: err.message })); + }); +} + +function serveStatic(req, res) { + const filePath = path.join(__dirname, 'static', req.url === '/' ? 'index.html' : req.url); + const ext = path.extname(filePath); + + fs.readFile(filePath, (err, data) => { + if (err) { res.writeHead(404); res.end('Not found'); return; } + res.writeHead(200, { 'Content-Type': MIME[ext] || 'text/plain' }); + res.end(data); + }); +} + +const server = http.createServer((req, res) => { + if (req.url.startsWith('/api/bonds')) { + proxyOnvista(req, res); + } else { + serveStatic(req, res); + } +}); + +server.listen(PORT, () => console.log(`Bond Sniffer running at http://localhost:${PORT}`)); diff --git a/static/index.html b/static/index.html new file mode 100644 index 0000000..4f31c02 --- /dev/null +++ b/static/index.html @@ -0,0 +1,357 @@ + + + + + + Bond Sniffer + + + + +

Bond Sniffer

+

Source: onvista.de — no API key required

+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+ +
+ + +
+
+
+ + +
+
+ + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + +