const {app} = require('./app');
const {pool} = require('./config/db');
const {env} = require('./config/env');

async function start() {
  await pool.query('SELECT 1');
  app.listen(env.port, () => {
    console.log(`Pawn Jewelry Shop backend running on http://localhost:${env.port}`);
  });
}

start().catch(error => {
  console.error('Failed to start backend', error);
  process.exit(1);
});
