diff --git a/src/plugin.test.ts b/src/plugin.test.ts index ba2e575..2b80167 100644 --- a/src/plugin.test.ts +++ b/src/plugin.test.ts @@ -326,7 +326,7 @@ describe('Plugin', () => { new Promise((resolve) => { const to = ZonedDateTime.now(ZoneId.UTC) getValues( - plugin.skInfluxes[0], + plugin.skInfluxes()[0], TESTCONTEXT as Context, from, to, diff --git a/src/plugin.ts b/src/plugin.ts index f9b99a7..e0299e7 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -56,7 +56,7 @@ export interface InfluxPlugin { getValues: (params: QueryParams) => Promise> getSelfValues: (params: Omit) => Promise> flush: () => Promise - skInfluxes: SKInflux[] + skInfluxes: () => SKInflux[] } export interface PluginConfig { @@ -71,7 +71,7 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin { delete writeOptionsProps.writeSuccess const selfContext = 'vessels.' + app.selfId - const skInfluxes: SKInflux[] = [] + let skInfluxes: SKInflux[] = [] let onStop: (() => void)[] = [] return { start: function (config: PluginConfig) { @@ -85,7 +85,7 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin { .join(';'), ) } - skInfluxes.push(...config.influxes.map((config: SKInfluxConfig) => new SKInflux(config, app, updatePluginStatus))) + skInfluxes = config.influxes.map((config: SKInfluxConfig) => new SKInflux(config, app, updatePluginStatus)) registerHistoryApiRoute(app, skInfluxes[0], app.selfId, app.debug) onStop = [] @@ -136,6 +136,6 @@ export default function InfluxPluginFactory(app: App): Plugin & InfluxPlugin { name: packageInfo.description, description: 'Signal K integration with InfluxDb 2', schema, - skInfluxes, + skInfluxes: () => skInfluxes, } }