From 62e8465a9453e85b1c776a6e3edab3f30410b63d Mon Sep 17 00:00:00 2001 From: Dominic Ferrando Date: Sat, 22 Aug 2026 18:49:56 -0400 Subject: [PATCH] Define Data interface for DataService --- src/services/data.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/services/data.ts b/src/services/data.ts index 37b40b9..3c717cf 100644 --- a/src/services/data.ts +++ b/src/services/data.ts @@ -1,15 +1,22 @@ +interface Data { + limboMode: boolean +} + export default class DataService { private static file: Bun.BunFile | undefined; - private static _data: Record = {}; + private static _data: Data = { + // default values (will be overwritten) + limboMode: false + }; static async load() { this.file = Bun.file("./data.json"); if (!(await this.file.exists())) - await Bun.write(this.file, JSON.stringify({}, null, 2)); - this._data = await this.file.json(); + await Bun.write(this.file, JSON.stringify(this._data, null, 2)); + this._data = { ...this._data, ...(await this.file.json()) }; } - static set data(data: Record) { + static set data(data: Data) { if (!this.file) throw new Error("DataService is not loaded. Please call DataService.load()"); this._data = data; void Bun.write(this.file, JSON.stringify(this._data, null, 2));