mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-13 00:18:50 +00:00
refactor widget api design
this passes all widget API calls through the backend, with a pluggable design and reusable API handlers
This commit is contained in:
parent
975f79f6cc
commit
97bf174b78
27 changed files with 370 additions and 252 deletions
|
@ -1,23 +0,0 @@
|
|||
import RuTorrent from "rutorrent-promise";
|
||||
|
||||
// TODO: Remove the 3rd party dependency once I figure out how to
|
||||
// call this myself with fetch. Just need to destruct the package.
|
||||
|
||||
export default async function handler(req, res) {
|
||||
const { url, username, password } = req.query;
|
||||
|
||||
const constructedUrl = new URL(url);
|
||||
|
||||
const rutorrent = new RuTorrent({
|
||||
host: constructedUrl.hostname, // default: localhost
|
||||
port: constructedUrl.port, // default: 80
|
||||
path: constructedUrl.pathname, // default: /rutorrent
|
||||
ssl: constructedUrl.protocol === "https:", // default: false
|
||||
username: username, // default: none
|
||||
password: password, // default: none
|
||||
});
|
||||
|
||||
const data = await rutorrent.get(["d.get_down_rate", "d.get_up_rate", "d.get_state"]);
|
||||
|
||||
res.status(200).send(data);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue