💄 Prettier repository
This commit is contained in:
@@ -6,7 +6,7 @@ export const findAppProperty = (app: ConfigAppType, key: IntegrationField) =>
|
||||
/** Checks if the type of an integration is part of the TIntegrations array with propper typing */
|
||||
export const checkIntegrationsType = <
|
||||
TTest extends CheckIntegrationTypeInput,
|
||||
TIntegrations extends readonly IntegrationType[]
|
||||
TIntegrations extends readonly IntegrationType[],
|
||||
>(
|
||||
test: TTest | undefined | null,
|
||||
integrations: TIntegrations
|
||||
@@ -21,7 +21,7 @@ type CheckIntegrationTypeInput = {
|
||||
|
||||
type CheckIntegrationType<
|
||||
TInput extends CheckIntegrationTypeInput,
|
||||
TIntegrations extends readonly IntegrationType[]
|
||||
TIntegrations extends readonly IntegrationType[],
|
||||
> = TInput & {
|
||||
type: TIntegrations[number];
|
||||
};
|
||||
|
||||
@@ -10,9 +10,9 @@ const ranges = [
|
||||
export const formatNumber = (n: number, decimalPlaces: number) => {
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
for (const range of ranges) {
|
||||
if (n < range.divider) continue;
|
||||
if (n < range.divider) continue;
|
||||
|
||||
return (n / range.divider).toFixed(decimalPlaces) + range.suffix;
|
||||
return (n / range.divider).toFixed(decimalPlaces) + range.suffix;
|
||||
}
|
||||
return n.toFixed(decimalPlaces);
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
import { MantineTheme } from '@mantine/core';
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
type colorThemeContextType = {
|
||||
primaryColor: MantineTheme['primaryColor'];
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { BackendConfigType } from '../../types/config';
|
||||
import { Config } from '../types';
|
||||
import { migrateConfig } from './migrateConfig';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { generateConfigPath } from './generateConfigPath';
|
||||
|
||||
export const configExists = (name: string) => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Consola from 'consola';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { BackendConfigType, ConfigType } from '../../types/config';
|
||||
import { backendMigrateConfig } from './backendMigrateConfig';
|
||||
import { configExists } from './configExists';
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import Consola from 'consola';
|
||||
import fs from 'fs';
|
||||
import { fetchCity } from '~/server/api/routers/weather';
|
||||
import { IntegrationField } from '~/types/app';
|
||||
|
||||
import { BackendConfigType, ConfigType } from '../../types/config';
|
||||
import { getConfig } from './getConfig';
|
||||
import { fetchCity } from '~/server/api/routers/weather';
|
||||
|
||||
export const getFrontendConfig = async (name: string): Promise<ConfigType> => {
|
||||
let config = getConfig(name);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import Consola from 'consola';
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
import { ConfigAppIntegrationType, ConfigAppType, IntegrationType } from '../../types/app';
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { generateConfigPath } from './generateConfigPath';
|
||||
|
||||
export function readConfig(name: string) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import { BackendConfigType } from '../../types/config';
|
||||
import { generateConfigPath } from './generateConfigPath';
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { getFallbackConfig } from './config/getFallbackConfig';
|
||||
import path from 'path';
|
||||
|
||||
import { ConfigType } from '../types/config';
|
||||
import { getFallbackConfig } from './config/getFallbackConfig';
|
||||
|
||||
export function getConfig(name: string, props: any = undefined) {
|
||||
// Check if the config file exists
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
|
||||
import {
|
||||
AbstractIconRepository,
|
||||
NormalizedIcon,
|
||||
|
||||
@@ -30,12 +30,14 @@ export const adGuardApiStatusResponseSchema = z.object({
|
||||
});
|
||||
|
||||
export const adGuardApiFilteringStatusSchema = z.object({
|
||||
filters: z.array(z.object({
|
||||
url: z.string().url(),
|
||||
name: z.string(),
|
||||
last_updated: z.string().optional(),
|
||||
id: z.number().nonnegative(),
|
||||
rules_count: z.number().nonnegative(),
|
||||
enabled: z.boolean(),
|
||||
})),
|
||||
filters: z.array(
|
||||
z.object({
|
||||
url: z.string().url(),
|
||||
name: z.string(),
|
||||
last_updated: z.string().optional(),
|
||||
id: z.number().nonnegative(),
|
||||
rules_count: z.number().nonnegative(),
|
||||
enabled: z.boolean(),
|
||||
})
|
||||
),
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import Consola from 'consola';
|
||||
import { vi, describe, it, expect } from 'vitest';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { PiHoleClient } from './piHole';
|
||||
|
||||
describe('PiHole API client', () => {
|
||||
@@ -307,7 +308,9 @@ describe('PiHole API client', () => {
|
||||
const client = new PiHoleClient('http://pi.hole', 'nice');
|
||||
|
||||
// Act & Assert
|
||||
await expect(() => client.disable()).rejects.toThrowErrorMatchingInlineSnapshot('"Status code does not indicate success: 404"');
|
||||
await expect(() => client.disable()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
'"Status code does not indicate success: 404"'
|
||||
);
|
||||
expect(calledCount).toBe(1);
|
||||
|
||||
expect(errorLogSpy).not.toHaveBeenCalled();
|
||||
@@ -335,7 +338,9 @@ describe('PiHole API client', () => {
|
||||
const client = new PiHoleClient('http://pi.hole', 'nice');
|
||||
|
||||
// Act & Assert
|
||||
await expect(() => client.disable()).rejects.toThrowErrorMatchingInlineSnapshot('"Response does not indicate success. Authentication is most likely invalid: "');
|
||||
await expect(() => client.disable()).rejects.toThrowErrorMatchingInlineSnapshot(
|
||||
'"Response does not indicate success. Authentication is most likely invalid: "'
|
||||
);
|
||||
expect(calledCount).toBe(1);
|
||||
|
||||
expect(errorLogSpy).not.toHaveBeenCalled();
|
||||
|
||||
@@ -4,7 +4,10 @@ import { PiHoleApiStatusChangeResponse, PiHoleApiSummaryResponse } from './piHol
|
||||
export class PiHoleClient {
|
||||
private readonly baseHostName: string;
|
||||
|
||||
constructor(hostname: string, private readonly apiToken: string) {
|
||||
constructor(
|
||||
hostname: string,
|
||||
private readonly apiToken: string
|
||||
) {
|
||||
this.baseHostName = trimStringEnding(hostname, ['/admin/index.php', '/admin', '/']);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
|
||||
import 'vitest-fetch-mock';
|
||||
|
||||
import { PlexClient } from './plexClient';
|
||||
|
||||
@@ -6,7 +6,10 @@ import {
|
||||
} from '../../../../types/api/media-server/session-info';
|
||||
|
||||
export class PlexClient {
|
||||
constructor(private readonly apiAddress: string, private readonly token: string) {}
|
||||
constructor(
|
||||
private readonly apiAddress: string,
|
||||
private readonly token: string
|
||||
) {}
|
||||
|
||||
async getSessions(): Promise<GenericSessionInfo[]> {
|
||||
const response = await fetch(`${this.apiAddress}/status/sessions?X-Plex-Token=${this.token}`);
|
||||
@@ -43,8 +46,8 @@ export class PlexClient {
|
||||
const transcodingElement = this.findElement('TranscodeSession', videoElement.elements);
|
||||
|
||||
return {
|
||||
id: (sessionElement?.id as string | undefined),
|
||||
username: userElement?.title ?? 'Anonymous' as string,
|
||||
id: sessionElement?.id as string | undefined,
|
||||
username: userElement?.title ?? ('Anonymous' as string),
|
||||
userProfilePicture: userElement?.thumb as string | undefined,
|
||||
sessionName: `${playerElement.product} (${playerElement.title})`,
|
||||
currentlyPlaying: {
|
||||
|
||||
Reference in New Issue
Block a user