Spaces:
Configuration error
Configuration error
File size: 485 Bytes
6ce9b06 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ```typescript
import fs from "fs";
import path from "path";
const dbPath = path.resolve("src/storage/projects.json");
export type ProjectDB = { projects: { id: string; name: string; createdAt: number }[] };
export function readProjects(): ProjectDB {
if (!fs.existsSync(dbPath)) return { projects: [] };
return JSON.parse(fs.readFileSync(dbPath, "utf-8"));
}
export function writeProjects(db: ProjectDB) {
fs.writeFileSync(dbPath, JSON.stringify(db, null, 2), "utf-8");
}
``` |