Files
embycovers/homescreen_editor/routes/+page.server.js
T

31 lines
832 B
JavaScript
Raw Normal View History

2026-06-08 21:58:16 +12:00
import { readFileSync, existsSync } from 'fs';
import { resolve } from 'path';
import { applyCachedEmbyNames } from '../lib/server/emby-user-cache.js';
/** @type {import('./$types').PageServerLoad} */
export async function load() {
const dataPath = resolve('static/db_export.json');
const raw = readFileSync(dataPath, 'utf-8');
const data = JSON.parse(raw);
const enrichedUsers = applyCachedEmbyNames(data.users);
const configPath = resolve('config.json');
let config = { embyUrl: '', apiKey: '', tmdbApiKey: '', dbPath: '' };
if (existsSync(configPath)) {
try {
config = {
...config,
...JSON.parse(readFileSync(configPath, 'utf-8'))
};
} catch { /* use defaults */ }
}
return {
users: enrichedUsers.users,
genres: data.genres,
enums: data.enums,
config,
embyCache: enrichedUsers.cache
};
}