diff --git a/nodecg-io-intellij/extension/index.ts b/nodecg-io-intellij/extension/index.ts index a6d83e0db..6988db275 100644 --- a/nodecg-io-intellij/extension/index.ts +++ b/nodecg-io-intellij/extension/index.ts @@ -3,7 +3,7 @@ import { Result, emptySuccess, success, ServiceBundle } from "nodecg-io-core"; import { IntelliJ } from "./intellij"; interface IntelliJServiceConfig { - address: string; + address?: string; } export type IntelliJServiceClient = IntelliJ; @@ -14,8 +14,7 @@ module.exports = (nodecg: NodeCG) => { class IntellijService extends ServiceBundle { async validateConfig(config: IntelliJServiceConfig): Promise> { - const address = config.address; - const ij = new IntelliJ(address); + const ij = new IntelliJ(config.address); await ij.rawRequest("available_methods", {}); return emptySuccess(); } @@ -23,7 +22,7 @@ class IntellijService extends ServiceBundle> { const ij = new IntelliJ(config.address); await ij.rawRequest("available_methods", {}); - this.nodecg.log.info(`Successfully connected to IntelliJ at ${config.address}.`); + this.nodecg.log.info(`Successfully connected to IntelliJ at ${ij.address}.`); return success(ij); } diff --git a/nodecg-io-intellij/extension/intellij.ts b/nodecg-io-intellij/extension/intellij.ts index 850471d0e..11b8545e5 100644 --- a/nodecg-io-intellij/extension/intellij.ts +++ b/nodecg-io-intellij/extension/intellij.ts @@ -1,17 +1,17 @@ import fetch from "node-fetch"; export class IntelliJ { - private readonly address: string; + readonly address: string; readonly pluginManager: PluginManager; readonly localHistory: LocalHistory; - public constructor(address: string) { - this.address = address; - if (address.includes("://")) { + constructor(address?: string) { + // Check if protocol is defined and default to http if missing + if (address?.includes("://")) { this.address = address; } else { - this.address = "http://" + address; + this.address = `http://${address ?? "127.0.0.1:19524"}`; } this.pluginManager = new PluginManager(this); diff --git a/nodecg-io-intellij/intellij-schema.json b/nodecg-io-intellij/intellij-schema.json index 9d6b14769..cdd1b5598 100644 --- a/nodecg-io-intellij/intellij-schema.json +++ b/nodecg-io-intellij/intellij-schema.json @@ -8,5 +8,5 @@ "description": "The address where the nodecg-io-intellij server runs. This defaults to 127.0.0.1:19524" } }, - "required": ["address"] + "required": [] }