Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbenincasa committed Mar 22, 2024
1 parent e2f94c2 commit dabbb95
Show file tree
Hide file tree
Showing 3 changed files with 300 additions and 235 deletions.
6 changes: 3 additions & 3 deletions server/src/api/plexServersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
import { PlexServerSettingsSchema } from '@tunarr/types/schemas';
import { isError, isNil, isObject } from 'lodash-es';
import z from 'zod';
import { PlexServerSettings } from '../dao/entities/PlexServerSettings.js';
import createLogger from '../logger.js';
import { Plex, PlexApiFactory } from '../plex.js';
import { scheduledJobsById } from '../services/scheduler.js';
import { UpdateXmlTvTask } from '../tasks/updateXmlTvTask.js';
import { RouterPluginAsyncCallback } from '../types/serverType.js';
import { firstDefined, wait } from '../util.js';
import { PlexServerSettings } from '../dao/entities/PlexServerSettings.js';

const logger = createLogger(import.meta);

Expand Down Expand Up @@ -51,7 +51,7 @@ export const plexServersRouter: RouterPluginAsyncCallback = async (
response: {
200: z.object({
// TODO Change this, this is very stupid
status: z.union([z.literal(1), z.literal(-1)]),
status: z.boolean(),
}),
404: z.void(),
500: z.void(),
Expand Down Expand Up @@ -80,7 +80,7 @@ export const plexServersRouter: RouterPluginAsyncCallback = async (
]);

return res.send({
status: s,
status: s === 1,
});
} catch (err) {
logger.error(err);
Expand Down
24 changes: 24 additions & 0 deletions web/src/external/api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
BaseErrorSchema,
BatchLookupExternalProgrammingSchema,
CreateCustomShowRequestSchema,
CreateFillerListRequestSchema,
Expand Down Expand Up @@ -196,6 +197,29 @@ export const api = makeApi([
.build(),
response: z.any(),
},
{
method: 'get',
path: '/api/plex-servers/:id/status',
alias: 'getPlexServerStatus',
parameters: parametersBuilder()
.addPaths({
id: z.string(),
})
.build(),
response: z.object({
healthy: z.boolean(),
}),
errors: makeErrors([
{
status: 404,
schema: BaseErrorSchema,
},
{
status: 500,
schema: BaseErrorSchema,
},
]),
},
{
method: 'get',
path: '/api/jobs',
Expand Down
Loading

0 comments on commit dabbb95

Please sign in to comment.