text: const express = require("express");
  const mongoose = require("mongoose");
  const cookieSession = require("cookie-session");
  const passport = require("passport");
  const bodyParser = require("body-parser");
  const flash = require("connect-flash");
  const morgan = require("morgan");
  const cookieParser = require("cookie-parser");
  const session = require("express-session");
  const keys = require("./config/keys");
  require("./models/User");
  require("./models/Items");
  require("./services/passport");
  
  
  mongoose.Promise = global.Promise;
  mongoose.connect(keys.mongoURI, { useMongoClient: true });
  
  var cors = require('cors');
  
  const app = express();
  
  app.use(cors());
  
  app.use(bodyParser.json());
  app.use(morgan("dev")); // log every request to the console
  app.use(cookieParser()); // read cookies (needed for auth)
  
  app.use(
    cookieSession({
      maxAge: 30 * 24 * 60 * 60 * 1000,
      keys: [keys.cookieKey]
    })
  );
  
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(flash()); // use connect-flash for flash messages stored in session
  
  require("./routes/authroutes")(app);
  require("./routes/itemRoutes")(app);
  
  if (process.env.NODE_ENV === "production") {
    app.use(express.static("client/build"));
  
    const path = require("path");
    app.get("*", (req, res) => {
      res.sendFile(path.resolve(__dirname, "client", "build", "index.html"));
    });
  }
  
  const PORT = process.env.PORT || 5000;
  app.listen(PORT);
  