text: const express     = require("express"),
      app           = express(),
      bodyParser    = require("body-parser"),
      mongoose      = require("mongoose"),
      passport      = require('passport'),
      LocalStrategy = require('passport-local'),
      Campground    = require('./models/campground'),
      Comment       = require('./models/comment'),
      User          = require('./models/user'),
      seedDB        = require('./seeds');
      
  // requiring routes
  var commentRoutes       = require('./routes/comments'),
      campgroundRoutes    = require('./routes/campgrounds'),
      indexRoutes         = require('./routes/index')
      
  mongoose.connect("mongodb://localhost/yelp_camp_v9", {useMongoClient: true});
  app.use(bodyParser.urlencoded({extended: true}));
  app.set("view engine", "ejs");
  app.use(express.static(__dirname + "/public"));
  // seed the database
  // seedDB();
  
  // PASSPORT CONFIGURATION
  app.use(require('express-session')({
    secret: "Queenie best cat",
    resave: false,
    saveUninitialized: false
  }));
  app.use(passport.initialize());
  app.use(passport.session());
  passport.use(new LocalStrategy(User.authenticate()));
  passport.serializeUser(User.serializeUser());
  passport.deserializeUser(User.deserializeUser());
  
  app.use(function(req, res, next) {
    res.locals.currentUser = req.user;
    next();
  });
  
  // url to matching routes
  app.use('/', indexRoutes);
  app.use('/campgrounds', campgroundRoutes);
  app.use('/campgrounds/:id/comments', commentRoutes);
  
  // server listen
  app.listen(process.env.PORT, process.env.IP, function(){
  console.log("Server has started!");
  });