💄 Prettier codebase

This commit is contained in:
ajnart
2023-10-25 15:29:45 +02:00
parent 01ab01d159
commit 5ab0e5207b
99 changed files with 375 additions and 358 deletions

View File

@@ -1,7 +1,7 @@
import Consola from 'consola';
import { v4 as uuidv4 } from 'uuid';
import { BackendConfigType, ConfigType } from '~/types/config';
import { configExists } from './configExists';
import { getFallbackConfig } from './getFallbackConfig';
import { readConfig } from './readConfig';

View File

@@ -1,4 +1,5 @@
import { ConfigType } from '~/types/config';
import defaultConfig from '../../../data/configs/default.json';
export const getFallbackConfig = (name?: string) => ({
@@ -11,7 +12,7 @@ export const getFallbackConfig = (name?: string) => ({
export const getStaticFallbackConfig = (name: string): ConfigType => ({
schemaVersion: 1,
configProperties: {
name: name
name: name,
},
categories: [
{
@@ -55,7 +56,7 @@ export const getStaticFallbackConfig = (name: string): ConfigType => ({
},
accessibility: {
disablePingPulse: false,
replacePingDotsWithIcons: false
replacePingDotsWithIcons: false,
},
pageTitle: 'Homarr ⭐️',
logoImageUrl: '/imgs/logo/logo.png',

View File

@@ -2,8 +2,8 @@ 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';
export const getFrontendConfig = async (name: string): Promise<ConfigType> => {
@@ -139,11 +139,11 @@ const migrateAppConfigs = (config: BackendConfigType) => {
...app,
appearance: {
...app.appearance,
appNameStatus: app.appearance.appNameStatus?? 'normal',
positionAppName: app.appearance.positionAppName?? 'column',
appNameFontSize: app.appearance.appNameFontSize?? 16,
lineClampAppName: app.appearance.lineClampAppName?? 1,
}
}))
}
}
appNameStatus: app.appearance.appNameStatus ?? 'normal',
positionAppName: app.appearance.positionAppName ?? 'column',
appNameFontSize: app.appearance.appNameFontSize ?? 16,
lineClampAppName: app.appearance.lineClampAppName ?? 1,
},
})),
};
};

View File

@@ -1,6 +1,6 @@
import fs from 'fs';
import { BackendConfigType } from '~/types/config';
import { generateConfigPath } from './generateConfigPath';
export function writeConfig(config: BackendConfigType) {

View File

@@ -10,7 +10,7 @@ import { ParsedUrlQuery } from 'querystring';
export const checkForSessionOrAskForLogin = (
context: GetServerSidePropsContext<ParsedUrlQuery, PreviewData>,
session: Session | null,
accessCallback: () => boolean,
accessCallback: () => boolean
): GetServerSidePropsResult<any> | undefined => {
if (!session?.user) {
console.log('detected logged out user!');
@@ -26,8 +26,8 @@ export const checkForSessionOrAskForLogin = (
if (!accessCallback()) {
return {
props: {},
notFound: true
}
notFound: true,
};
}
return undefined;

View File

@@ -2,6 +2,7 @@ import axios from 'axios';
import Consola from 'consola';
import { z } from 'zod';
import { trimStringEnding } from '~/tools/shared/strings';
import {
adGuardApiFilteringStatusSchema,
adGuardApiStatsResponseSchema,

View File

@@ -171,7 +171,7 @@ describe('PiHole API client', () => {
});
}
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice'){
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice') {
countTriedRequests += 1;
return JSON.stringify({
status: 'enabled',
@@ -213,9 +213,9 @@ describe('PiHole API client', () => {
});
}
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice'){
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice') {
countTriedRequests += 1;
if(countTriedRequests < 10) {
if (countTriedRequests < 10) {
return JSON.stringify({
status: 'disabled',
});
@@ -261,7 +261,7 @@ describe('PiHole API client', () => {
});
}
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice'){
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice') {
countTriedRequests += 1;
return JSON.stringify({
status: 'disabled',
@@ -303,9 +303,9 @@ describe('PiHole API client', () => {
});
}
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice'){
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice') {
countTriedRequests += 1;
if(countTriedRequests < 10) {
if (countTriedRequests < 10) {
return JSON.stringify({
status: 'enabled',
});
@@ -351,7 +351,7 @@ describe('PiHole API client', () => {
});
}
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice'){
if (request.url === 'http://pi.hole/admin/api.php?summaryRaw&auth=nice') {
countTriedRequests += 1;
return JSON.stringify({
status: 'disabled',

View File

@@ -1,4 +1,5 @@
import { trimStringEnding } from '~/tools/shared/strings';
import { PiHoleApiStatusChangeResponse, PiHoleApiSummaryResponse } from './piHole.type';
export class PiHoleClient {
@@ -62,18 +63,18 @@ export class PiHoleClient {
);
}
for(let loops = 0; loops < 10; loops++){
const summary = await this.getSummary()
if (summary.status === action + 'd'){
for (let loops = 0; loops < 10; loops++) {
const summary = await this.getSummary();
if (summary.status === action + 'd') {
return { status: summary.status } as PiHoleApiStatusChangeResponse;
}
await new Promise ((resolve) => { setTimeout(resolve, 50)});
await new Promise((resolve) => {
setTimeout(resolve, 50);
});
}
return Promise.reject(
new Error(
`Although PiHole received the command, it failed to update it's status: ${json}`
)
)
new Error(`Although PiHole received the command, it failed to update it's status: ${json}`)
);
}
}

View File

@@ -1,9 +1,5 @@
import { Element, xml2js } from 'xml-js';
import {
GenericCurrentlyPlaying,
GenericSessionInfo,
} from '~/types/api/media-server/session-info';
import { GenericCurrentlyPlaying, GenericSessionInfo } from '~/types/api/media-server/session-info';
export class PlexClient {
constructor(
@@ -44,7 +40,6 @@ export class PlexClient {
const { videoCodec, videoFrameRate, audioCodec, audioChannels, height, width, bitrate } =
mediaElement;
return {
id: sessionElement?.id as string | undefined,
username: userElement?.title ?? ('Anonymous' as string),

View File

@@ -11,7 +11,7 @@ export const generateDefaultApp = (wrapperId: string): AppType =>
appNameStatus: 'normal',
positionAppName: 'column',
lineClampAppName: 1,
appNameFontSize: 16
appNameFontSize: 16,
},
network: {
enabledStatusChecker: true,