🏗️ Migrate usenet info to tRPC
This commit is contained in:
22
src/server/api/routers/usenet/nzbget/nzbget-client.ts
Normal file
22
src/server/api/routers/usenet/nzbget/nzbget-client.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user