text: // required modules
  const express = require("express");
  const mongoose = require("mongoose");
  
  // create PORT
  const PORT = process.env.PORT || 8080;
  
  // express instance
  const app = express();
  
  // add middleware
  app.use(express.urlencoded({ extended: true }));
  app.use(express.json());
  
  app.use(express.static("public"));
  
  require("./routes/apiRoutes")(app);
  require("./routes/htmlRoutes")(app);
  
  mongoose.connect(process.env.MONGODB_URI || "mongodb://localhost/workout", {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useFindAndModify: false,
    useCreateIndex: true,
  });
  
  const connection = mongoose.connection;
  
  connection.on("connected", () => {
    console.log("Mongoose connected successfully.");
  });
  
  connection.on("error", (err) => {
    console.log("Mongoose connection error: " + err);
  });
  
  app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
  });