Files
InvestmentsVisualizer/server/jsonStore.ts
Dasemu 1dae56415c Initial commit: investment dashboard with contributions panel and forecast chart
React + Vite frontend with a local-JSON-backed API (Vite middleware) for
tracking portfolio holdings, contributions/withdrawals, recurring
contribution plans, and a forecast chart comparing the portfolio's real
value against a same-contributions S&P 500 benchmark.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-30 19:18:46 +02:00

18 lines
496 B
TypeScript

import { readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
const DATA_DIR = join(process.cwd(), "data");
export function dataPath(file: string): string {
return join(DATA_DIR, file);
}
export function readJson<T>(file: string): T {
const raw = readFileSync(dataPath(file), "utf-8");
return JSON.parse(raw) as T;
}
export function writeJson<T>(file: string, data: T): void {
writeFileSync(dataPath(file), JSON.stringify(data, null, 2) + "\n", "utf-8");
}