🐯 Added a prowlarr api test endpoint

This commit is contained in:
2023-09-07 10:04:29 -04:00
parent 44f612c52f
commit 9c10347d38
4 changed files with 134 additions and 16 deletions

View File

@@ -0,0 +1,39 @@
"use strict";
import { Context, Service, ServiceBroker, ServiceSchema, Errors } from "moleculer";
import { qBittorrentClient } from "@robertklep/qbittorrent";
const { MoleculerError } = require("moleculer").Errors;
export default class QBittorrentService extends Service {
// @ts-ignore
public constructor(
public broker: ServiceBroker,
schema: ServiceSchema<{}> = { name: "qbittorrent" },
) {
super(broker);
this.parseServiceSchema({
name: "qbittorrent",
mixins: [],
hooks: {},
actions: {
getList: {
rest: "GET /getTorrents",
handler: async (ctx: Context<{}>) => {
return await this.torrentClient.torrents.info()
}
}
}, methods: {},
async started(): Promise<any> {
try {
this.torrentClient = new qBittorrentClient("http://192.168.1.183:8089", "admin", "adminadmin");
} catch (err) {
throw new MoleculerError(err, 500, "QBITTORRENT_CONNECTION_ERROR", {
data: err,
});
}
}
});
}
}