mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 07:25:48 +01:00
🎨 Rename "services" to "apps" in entire project
This commit is contained in:
@@ -9,32 +9,32 @@ import { NzbgetClient } from './nzbget/nzbget-client';
|
||||
dayjs.extend(duration);
|
||||
|
||||
export interface UsenetPauseRequestParams {
|
||||
serviceId: string;
|
||||
appId: string;
|
||||
}
|
||||
|
||||
async function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||
try {
|
||||
const configName = getCookie('config-name', { req });
|
||||
const config = getConfig(configName?.toString() ?? 'default');
|
||||
const { serviceId } = req.query as any as UsenetPauseRequestParams;
|
||||
const { appId } = req.query as any as UsenetPauseRequestParams;
|
||||
|
||||
const service = config.services.find((x) => x.id === serviceId);
|
||||
const app = config.apps.find((x) => x.id === appId);
|
||||
|
||||
if (!service) {
|
||||
throw new Error(`Service with ID "${req.query.serviceId}" could not be found.`);
|
||||
if (!app) {
|
||||
throw new Error(`App with ID "${req.query.appId}" could not be found.`);
|
||||
}
|
||||
|
||||
let result;
|
||||
switch (service.integration?.type) {
|
||||
switch (app.integration?.type) {
|
||||
case 'nzbGet': {
|
||||
const url = new URL(service.url);
|
||||
const url = new URL(app.url);
|
||||
const options = {
|
||||
host: url.hostname,
|
||||
port: url.port,
|
||||
login:
|
||||
service.integration.properties.find((x) => x.field === 'username')?.value ?? undefined,
|
||||
app.integration.properties.find((x) => x.field === 'username')?.value ?? undefined,
|
||||
hash:
|
||||
service.integration.properties.find((x) => x.field === 'password')?.value ?? undefined,
|
||||
app.integration.properties.find((x) => x.field === 'password')?.value ?? undefined,
|
||||
};
|
||||
|
||||
const nzbGet = NzbgetClient(options);
|
||||
@@ -51,18 +51,18 @@ async function Post(req: NextApiRequest, res: NextApiResponse) {
|
||||
break;
|
||||
}
|
||||
case 'sabnzbd': {
|
||||
const apiKey = service.integration.properties.find((x) => x.field === 'apiKey')?.value;
|
||||
const apiKey = app.integration.properties.find((x) => x.field === 'apiKey')?.value;
|
||||
if (!apiKey) {
|
||||
throw new Error(`API Key for service "${service.name}" is missing`);
|
||||
throw new Error(`API Key for app "${app.name}" is missing`);
|
||||
}
|
||||
|
||||
const { origin } = new URL(service.url);
|
||||
const { origin } = new URL(app.url);
|
||||
|
||||
result = await new Client(origin, apiKey).queuePause();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
throw new Error(`Service type "${service.integration?.type}" unrecognized.`);
|
||||
throw new Error(`App type "${app.integration?.type}" unrecognized.`);
|
||||
}
|
||||
|
||||
return res.status(200).json(result);
|
||||
|
||||
Reference in New Issue
Block a user