Initial code

This commit is contained in:
Aslan 2025-12-23 07:18:10 -05:00
commit 1f20a611da
26 changed files with 1050 additions and 0 deletions

25
src/store/store.ts Normal file
View file

@ -0,0 +1,25 @@
import config from "../config.json" with { type: "json" };
import { existsSync, readFileSync, writeFileSync } from "fs";
import type { IState } from "./types.js";
let state: IState = {
users: [],
};
const load = () => {
if (!existsSync(config.storePath)) {
return;
}
const json = readFileSync(config.storePath).toString();
state = JSON.parse(json) as IState;
};
const save = () => {
const json = JSON.stringify(state);
writeFileSync(config.storePath, json);
};
export { state, load, save };