import './config/env.js'; import { startApi, stopApi } from './api/index.js'; import { closeStore } from './db/store.js'; async function shutdown() { await stopApi(); try { await closeStore(); } catch (error) { console.error('Failed to close database:', error); process.exitCode = 1; } } process.on('SIGINT', () => { shutdown().then(() => process.exit(0)); }); process.on('SIGTERM', () => { shutdown().then(() => process.exit(0)); }); startApi().catch((err) => { console.error('Failed to start API:', err.message); process.exit(1); });