formatting

This commit is contained in:
Darius
2026-02-06 15:43:14 +01:00
parent 350d7dee3e
commit a8280ce27f
6 changed files with 62 additions and 62 deletions

View File

@@ -3,22 +3,22 @@ import dotenv from "dotenv";
dotenv.config(); dotenv.config();
export const Config = { export const Config = {
api_key: process.env.API_KEY, api_key: process.env.API_KEY,
port: process.env.PORT || "8080", port: process.env.PORT || "8080",
env_dev: process.env.ENV_DEV || false, env_dev: process.env.ENV_DEV || false,
tidal: { tidal: {
host: process.env.TIDAL_HOST || "", host: process.env.TIDAL_HOST || "",
port: process.env.TIDAL_PORT || "", port: process.env.TIDAL_PORT || "",
}, },
homeassistant: { homeassistant: {
api_url: process.env.HA_API_URL || "", api_url: process.env.HA_API_URL || "",
api_token: process.env.HA_API_TOKEN || "", api_token: process.env.HA_API_TOKEN || "",
id_desk_sensor_binary: process.env.HA_DESK_SENSOR_BINARY || "", id_desk_sensor_binary: process.env.HA_DESK_SENSOR_BINARY || "",
id_room_sensors: process.env.HA_ROOMTEMP_SENSOR_IDS?.split(",") || [], id_room_sensors: process.env.HA_ROOMTEMP_SENSOR_IDS?.split(",") || [],
id_webhook_stand: process.env.HA_STANDING_WEBHOOK || "", id_webhook_stand: process.env.HA_STANDING_WEBHOOK || "",
}, },
} as const; } as const;

View File

@@ -2,37 +2,37 @@ import { BaseClient, type HomeAssistantEntity } from "@dpu/shared";
import { printNetworkError } from "@dpu/shared/dist/logger.js"; import { printNetworkError } from "@dpu/shared/dist/logger.js";
export class HomeAssistantClient extends BaseClient { export class HomeAssistantClient extends BaseClient {
async getEntityStates(entityIds: string[]): Promise<HomeAssistantEntity[]> { async getEntityStates(entityIds: string[]): Promise<HomeAssistantEntity[]> {
try { try {
const promises = entityIds.map((id) => this.getEntityState(id)); const promises = entityIds.map((id) => this.getEntityState(id));
return await Promise.all(promises); return await Promise.all(promises);
} catch (error) { } catch (error) {
printNetworkError(error); printNetworkError(error);
throw error; throw error;
} }
} }
async getEntityState(entityId: string): Promise<HomeAssistantEntity> { async getEntityState(entityId: string): Promise<HomeAssistantEntity> {
try { try {
const response = await this.getAxios().get<HomeAssistantEntity>( const response = await this.getAxios().get<HomeAssistantEntity>(
`states/${entityId}`, `states/${entityId}`,
); );
return response.data; return response.data;
} catch (error) { } catch (error) {
printNetworkError(error); printNetworkError(error);
throw error; throw error;
} }
} }
async triggerWebhook(webhookId: string): Promise<unknown> { async triggerWebhook(webhookId: string): Promise<unknown> {
try { try {
const response = await this.getAxios().post<HomeAssistantEntity>( const response = await this.getAxios().post<HomeAssistantEntity>(
`webhook/${webhookId}`, `webhook/${webhookId}`,
); );
return response.data; return response.data;
} catch (error) { } catch (error) {
printNetworkError(error); printNetworkError(error);
throw error; throw error;
} }
} }
} }

View File

@@ -1,7 +1,7 @@
import type { API_HA_DeskPosition, TidalGetCurrent } from "@dpu/shared";
import type { FastifyInstance } from "fastify"; import type { FastifyInstance } from "fastify";
import { z } from "zod"; import { z } from "zod";
import { type HomepageService } from "./service.js"; import type { HomepageService } from "./service.js";
import { type API_HA_DeskPosition, type TidalGetCurrent } from "@dpu/shared";
export async function homepageRoutes( export async function homepageRoutes(
fastify: FastifyInstance, fastify: FastifyInstance,

View File

@@ -1,14 +1,14 @@
import { import {
BaseService, BaseService,
FullInformation, type FullInformation,
HomeAssistantDeskPositionResult, type HomeAssistantDeskPositionResult,
TidalGetCurrent,
WsService,
type ServiceResult, type ServiceResult,
type TidalGetCurrent,
type WsService,
} from "@dpu/shared"; } from "@dpu/shared";
import { logInfo, logWarning } from "@dpu/shared/dist/logger.js"; import { logInfo, logWarning } from "@dpu/shared/dist/logger.js";
import { HomeAssistantService } from "../homeassistant/service"; import type { HomeAssistantService } from "../homeassistant/service";
import { TidalService } from "../tidal/service"; import type { TidalService } from "../tidal/service";
export class HomepageService extends BaseService<null> { export class HomepageService extends BaseService<null> {
private haService: HomeAssistantService; private haService: HomeAssistantService;

View File

@@ -1,6 +1,9 @@
import { WsService } from "@dpu/shared";
import { logInfo } from "@dpu/shared/dist/logger.js"; import { logInfo } from "@dpu/shared/dist/logger.js";
import fastifyCors from "@fastify/cors";
import fastifySwagger from "@fastify/swagger"; import fastifySwagger from "@fastify/swagger";
import fastifySwaggerUi from "@fastify/swagger-ui"; import fastifySwaggerUi from "@fastify/swagger-ui";
import fastifyWebsocket from "@fastify/websocket";
import type { FastifyReply, FastifyRequest } from "fastify"; import type { FastifyReply, FastifyRequest } from "fastify";
import Fastify from "fastify"; import Fastify from "fastify";
import fastifyAxios from "fastify-axios"; import fastifyAxios from "fastify-axios";
@@ -16,15 +19,12 @@ import { Config } from "./config.js";
import { HomeAssistantClient } from "./homeassistant/client.js"; import { HomeAssistantClient } from "./homeassistant/client.js";
import { homeAssistantRoutes } from "./homeassistant/routes.js"; import { homeAssistantRoutes } from "./homeassistant/routes.js";
import { HomeAssistantService } from "./homeassistant/service.js"; import { HomeAssistantService } from "./homeassistant/service.js";
import { TidalClient } from "./tidal/client.js";
import { TidalService } from "./tidal/service.js";
import { tidalRoutes } from "./tidal/routes.js";
import { wsRoutes } from "./websocket/routes.js";
import { HomepageService } from "./homepage/service.js";
import { homepageRoutes } from "./homepage/routes.js"; import { homepageRoutes } from "./homepage/routes.js";
import fastifyCors from "@fastify/cors"; import { HomepageService } from "./homepage/service.js";
import fastifyWebsocket from "@fastify/websocket"; import { TidalClient } from "./tidal/client.js";
import { WsService } from "@dpu/shared"; import { tidalRoutes } from "./tidal/routes.js";
import { TidalService } from "./tidal/service.js";
import { wsRoutes } from "./websocket/routes.js";
const fastify = Fastify().withTypeProvider<ZodTypeProvider>(); const fastify = Fastify().withTypeProvider<ZodTypeProvider>();

View File

@@ -1,5 +1,5 @@
import { logInfo, type WsService } from "@dpu/shared";
import type { FastifyInstance } from "fastify"; import type { FastifyInstance } from "fastify";
import { logInfo, WsService } from "@dpu/shared";
export async function wsRoutes( export async function wsRoutes(
fastify: FastifyInstance, fastify: FastifyInstance,