text: require('dotenv').config()
  const express = require("express");
  const path = require("path");
  const PORT = process.env.PORT || 3001;
  const app = express();
  const routes = require("./routes");
  const bodyParser = require('body-parser');
  const mongoose = require("mongoose");
  const passport = require("passport");
  const cors = require("cors");
  
  const users = require("./routes/api/users")
  app.use(cors());
  app.use(bodyParser.json());
  
  app.use(bodyParser.urlencoded({ extended: true }));
  
  // DB Config
  const db = require("./config/keys").mongoURI;
  // Connect to MongoDB
  mongoose
    .connect(
      db,
      { useNewUrlParser: true }
    )
    .then(() => console.log("MongoDB successfully connected"))
    .catch(err => console.log(err));
  
  mongoose.set('useFindAndModify', false);
    
  // Passport middleware
  app.use(passport.initialize());
  // Passport config
  require("./config/passport")(passport);
  // Routes
  app.use("/api/users", users);
  
  // Serve up static assets (usually on heroku)
  if (process.env.NODE_ENV === "production") {
    app.use(express.static("client/build"));
  }
  
  // Add routes, both API and view
  app.use(routes);
  
  
  app.listen(PORT, function() {
    console.log(`🌎 ==> API server now on port ${PORT}!`);
  });
  