const port = process.env.PORT || 3000,
  express = require("express"),
  app = express(),
  db = require("./models"),
  cors = require("cors"),
  bodyParser = require("body-parser");

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.use("/auth", require("./routes/auth"));

app.listen(port, () => {
  console.log(`Server is running on port ${port}`);
});

db.sequelize
  .sync({ force: false })
  .then(() => {
    console.log("Connection has been established successfully.");
  })
  .catch((error) => {
    console.error("Unable to connect to the database:", error);
  });
