import app from "./app.js";
import { env } from "./config/env.js";
import { initDb } from "./config/initDb.js";

// Attempt to initialize database tables on startup
initDb().then(() => {
  app.listen(env.port, () => {
    console.log(`E-Notary API running on port ${env.port}`);
  });
}).catch(err => {
  console.error("Failed to start server due to database initialization error:", err);
  process.exit(1);
});
