Dashboard with YAML

This commit is contained in:
2026-04-19 18:03:14 +01:00
commit 9ed7f34c44
29 changed files with 26677 additions and 0 deletions

32
server/utils/yamlDb.ts Normal file
View File

@@ -0,0 +1,32 @@
import fs from 'fs';
import path from 'path';
import yaml from 'js-yaml';
const dbPath = path.resolve(process.cwd(), 'app/dashboard.yml');
export interface DashboardItem {
id: string;
type: 'folder' | 'link';
parentId: string | null;
name?: string;
slug?: string;
title?: string;
url?: string;
description?: string;
icon?: string;
color?: string;
order: number;
}
export function readDb(): DashboardItem[] {
if (!fs.existsSync(dbPath)) {
return [];
}
const fileContents = fs.readFileSync(dbPath, 'utf8');
return (yaml.load(fileContents) as DashboardItem[]) || [];
}
export function writeDb(data: DashboardItem[]) {
const yamlStr = yaml.dump(data);
fs.writeFileSync(dbPath, yamlStr, 'utf8');
}