Browse Source

Clean up torrent client API interface

dev
David Ludwig 4 years ago
parent
commit
6bc6a82df8
1 changed files with 13 additions and 2 deletions
  1. +13
    -2
      api/torrent/src/IpcClient.ts

+ 13
- 2
api/torrent/src/IpcClient.ts View File

@ -45,11 +45,22 @@ export abstract class IpcClient<M extends Microservice = Microservice> extends I
return <ITorrent[]>response.data;
}
/**
* Check if the torrent client has the given torrent
*/
public async has(torrentId: string) {
let response = await this.request("has", torrentId);
if (response.error) {
console.error(response.error);
throw new Error("Failed to check if a torrent exists");
}
return <Boolean>response.data;
}
/**
* Get full details of each of the provided torrents
* @param torrentIds Array of torrent info hashes
*/
public async details(...torrentIds: string[]) {
public async details(torrentIds: string[] = []) {
let response = await this.request("details", torrentIds);
if (response.error) {
console.error(response.error);


Loading…
Cancel
Save