v1
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { readFileSync, existsSync } from 'fs';
|
||||
import { resolve } from 'path';
|
||||
|
||||
/** @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 configPath = resolve('config.json');
|
||||
let config = { embyUrl: '', apiKey: '', dbPath: '' };
|
||||
if (existsSync(configPath)) {
|
||||
try {
|
||||
config = JSON.parse(readFileSync(configPath, 'utf-8'));
|
||||
} catch { /* use defaults */ }
|
||||
}
|
||||
|
||||
return {
|
||||
users: data.users,
|
||||
genres: data.genres,
|
||||
enums: data.enums,
|
||||
config
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user