From e08e52f91f1d1faf381cbb115926fc871a5eb1e9 Mon Sep 17 00:00:00 2001 From: Sam Stenvall Date: Wed, 18 Oct 2023 20:00:50 +0300 Subject: [PATCH] Make "characteristics" and "publishers" optional The app is functional without either of these --- src/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.ts b/src/config.ts index a2f5720..4a09c1b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -24,9 +24,9 @@ import { ConsolePublisher, ConsolePublisherImpl } from './publisher/console' import { Characteristics } from './characteristics' export interface Config { - characteristics: Characteristics[] + characteristics?: Characteristics[] circuits: Circuit[] - publishers: Publisher[] + publishers?: Publisher[] } export const parseConfig = (configFileContents: string): Config => { @@ -116,7 +116,7 @@ export const resolveAndValidateConfig = (config: Config): Config => { } // Attach poll function to characteristics sensors - for (const c of config.characteristics) { + for (const c of config?.characteristics ?? []) { switch (c.sensor.type) { case CharacteristicsSensorType.Iotawatt: c.sensor.pollFunc = getIotawattCharacteristicsSensorData @@ -129,7 +129,7 @@ export const resolveAndValidateConfig = (config: Config): Config => { // Create publishers. Ignore any manually defined WebSocket publishers, we only support // one right now and it's added separately during application startup. - for (const publisher of config.publishers) { + for (const publisher of config?.publishers ?? []) { switch (publisher.type) { case PublisherType.InfluxDB: { const influxDbPublisher = publisher as InfluxDBPublisher