text: /**
   * Module dependencies.
   */
  const express = require('express');
  const compression = require('compression');
  const session = require('express-session');
  const bodyParser = require('body-parser');
  const logger = require('morgan');
  const chalk = require('chalk');
  const errorHandler = require('errorhandler');
  const lusca = require('lusca');
  const MongoStore = require('connect-mongo')(session);
  const flash = require('express-flash');
  const path = require('path');
  const mongoose = require('mongoose');
  const passport = require('passport');
  const expressValidator = require('express-validator');
  const sass = require('node-sass-middleware');
  
  /**
   * Controllers (route handlers).
   */
  const apiController = require('./controllers/api');
  
  /**
   * API keys and Passport configuration.
   */
  const config = require('config');
  const passportConfig = require('./config/lib/passport');
  
  /**
   * Create Express server.
   */
  const app = express();
  
  /**
   * Connect to MongoDB.
   */
  mongoose.Promise = global.Promise;
  mongoose.connect(config.get('db.uri'), {
      useMongoClient: true
  });
  mongoose.connection.on('error', (err) => {
      console.error(err);
      console.log('%s MongoDB connection error. Please make sure MongoDB is running.', chalk.red('✗'));
      process.exit();
  });
  
  /**
   * Express configuration.
   */
  app.set('port', config.get('port') || 3000);
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine', 'pug');
  app.use(compression());
  app.use(sass({
      src: path.join(__dirname, 'public')
      , dest: path.join(__dirname, 'public')
  }));
  app.use(logger('dev'));
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({
      extended: false
  }));
  app.use(expressValidator());
  
  app.use(passport.initialize());
  
  app.use(express.static(path.join(__dirname, 'public'), {
      maxAge: 31557600000
  }));
  
  /**
   * Routes
   */
  app.use('/api/user', require('./routes/user.routes'));
  app.use('/auth', require('./routes/auth.routes'))
  app.use('/shop', require('./routes/shop.routes'))
  app.use('/', require('./routes/index'));
  
  
  
  /**
   * API examples routes.
   */
  app.get('/api', apiController.getApi);
  app.get('/api/stripe', apiController.getStripe);
  app.post('/api/stripe', apiController.postStripe);
  app.get('/api/twitter', passportConfig.isAuthenticated, passportConfig.isAuthorized, apiController.getTwitter);
  app.post('/api/twitter', passportConfig.isAuthenticated, passportConfig.isAuthorized, apiController.postTwitter);
  app.get('/api/paypal', apiController.getPayPal);
  app.get('/api/paypal/success', apiController.getPayPalSuccess);
  app.get('/api/paypal/cancel', apiController.getPayPalCancel);
  app.get('/api/google-maps', apiController.getGoogleMaps);
  app.get('/api/error', apiController.getError);
  
  /**
   * Error Handler.
   */
  app.use(errorHandler());
  
  /**
   * Start Express server.
   */
  app.listen(app.get('port'), () => {
      console.log('%s App is running at http://localhost:%d in %s mode', chalk.green('✓'), app.get('port'), app.get('env'));
      console.log('  Press CTRL-C to stop\n');
  });
  
  module.exports = app;
  