Files
homarr/src/server/api/routers/usenet/nzbget/nzbget-client.ts
2023-06-10 17:20:06 +02:00

23 lines
611 B
TypeScript

import NZBGet from 'nzbget-api';
import { NzbgetClientOptions } from './types';
export function NzbgetClient(options: NzbgetClientOptions) {
if (!options?.host) {
throw new Error('Cannot connect to NZBGet. Missing host in app config.');
}
if (!options?.port) {
throw new Error('Cannot connect to NZBGet. Missing port in app config.');
}
if (!options?.login) {
throw new Error('Cannot connect to NZBGet. Missing username in app config.');
}
if (!options?.hash) {
throw new Error('Cannot connect to NZBGet. Missing password in app config.');
}
return new NZBGet(options);
}