From 0124b6a7fc1ecfc07ebd0693c0c276a805bce5ed Mon Sep 17 00:00:00 2001 From: David Barrat Date: Mon, 3 Feb 2025 16:48:09 +0100 Subject: [PATCH] feat: simplify Kadoa logic --- node/src/index.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/node/src/index.ts b/node/src/index.ts index f954e4f..9dbe65b 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -1,20 +1,16 @@ import { Realtime } from "./realtime"; + export class Kadoa { - private teamApiKey?: string; private _realtime?: Realtime; - constructor(props: { apiKey?: string; teamApiKey?: string }) { - if (!props.apiKey && !props.teamApiKey) { - throw new Error("apiKey or teamApiKey must be passed"); + constructor(private teamApiKey?: string) { + if (!teamApiKey) { + throw new Error("teamApiKey must be provided"); } - this.teamApiKey = props.teamApiKey; } get realtime() { - if (!this._realtime) { - this._realtime = new Realtime(this.teamApiKey); - } - return this._realtime; + return this._realtime ??= new Realtime(this.teamApiKey); } }