formatting and grist
This commit is contained in:
15
src/index.ts
15
src/index.ts
@@ -16,6 +16,9 @@ import {
|
||||
import { SwaggerTheme, SwaggerThemeNameEnum } from "swagger-themes";
|
||||
import { z } from "zod";
|
||||
import { Config } from "./config.js";
|
||||
import { GristClient } from "./grist/client.js";
|
||||
import { gristRoutes } from "./grist/routes.js";
|
||||
import { GristService } from "./grist/service.js";
|
||||
import { HomeAssistantClient } from "./homeassistant/client.js";
|
||||
import { homeAssistantRoutes } from "./homeassistant/routes.js";
|
||||
import { HomeAssistantService } from "./homeassistant/service.js";
|
||||
@@ -69,6 +72,12 @@ await fastify.register(fastifySwaggerUi, {
|
||||
|
||||
await fastify.register(fastifyAxios, {
|
||||
clients: {
|
||||
grist: {
|
||||
baseURL: Config.grist.api_url,
|
||||
headers: {
|
||||
Authorization: `Bearer ${Config.grist.api_token}`,
|
||||
},
|
||||
},
|
||||
homeassistant: {
|
||||
baseURL: Config.homeassistant.api_url,
|
||||
headers: {
|
||||
@@ -76,13 +85,16 @@ await fastify.register(fastifyAxios, {
|
||||
},
|
||||
},
|
||||
tidal: {
|
||||
baseURL: `${Config.tidal.host}:${Config.tidal.port}`,
|
||||
baseURL: `${Config.tidal.address}`,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await fastify.register(fastifyWebsocket);
|
||||
|
||||
const gristClient = new GristClient(fastify.axios.grist);
|
||||
const gristService = new GristService(gristClient);
|
||||
|
||||
const haClient = new HomeAssistantClient(fastify.axios.homeassistant);
|
||||
const haService = new HomeAssistantService(haClient);
|
||||
|
||||
@@ -108,6 +120,7 @@ async function verifyAPIKey(
|
||||
const port = parseInt(Config.port, 10);
|
||||
|
||||
// Register routes
|
||||
await fastify.register(gristRoutes, { gristService });
|
||||
await fastify.register(homeAssistantRoutes, { haService, verifyAPIKey });
|
||||
await fastify.register(tidalRoutes, { tidalService, verifyAPIKey });
|
||||
await fastify.register(wsRoutes, { wsService });
|
||||
|
||||
Reference in New Issue
Block a user