🏗️ Parameterized connect endpoint

This commit is contained in:
2023-09-15 15:50:06 -04:00
parent e49c9c985a
commit 104e7ba0bb
4 changed files with 89 additions and 167 deletions

View File

@@ -16,14 +16,28 @@ export default class QBittorrentService extends Service {
actions: {
connect: {
rest: "POST /connect",
handler: async (ctx: Context<{}>) => {
const client = new qBittorrentClient(
"http://127.0.0.1:8080",
"admin",
"adminadmin",
handler: async (
ctx: Context<{
username: string;
password: string;
hostname: string;
port: string;
protocol: string;
name: string;
}>,
) => {
const { username, password, hostname, port, protocol } = ctx.params;
this.meta = new qBittorrentClient(
`${protocol}://${hostname}:${port}`,
`${username}`,
`${password}`,
);
console.log(client);
return { foo: "bar" };
},
},
getClientInfo: {
rest: "GET /getClientInfo",
handler: async (ctx: Context<{}>) => {
return await this.meta.app.buildInfo();
},
},
},