import fs from 'node:fs'; import path from 'node:path'; const root = process.cwd(); const file = process.env.PORTFOLIO_CONFIG || path.join(root, 'data', 'config.json'); const example = path.join(root, 'config.example.json'); export function loadConfig() { if (!fs.existsSync(file)) { fs.mkdirSync(path.dirname(file), { recursive: true }); fs.copyFileSync(example, file); console.log(`Created ${file}; edit it to personalize your portfolio.`); } const config = JSON.parse(fs.readFileSync(file, 'utf8')); config.host ??= {}; config.host.port = Number(process.env.PORT || config.host.port || 2222); config.host.notificationPort = Number(process.env.NOTIFICATION_PORT || config.host.notificationPort || 7777); return config; } export const configPath = file;