text: "use strict";
  
  let express = require('express'),
      path = require('path'),
      favicon = require('serve-favicon'),
      logger = require('morgan'),
      cookieParser = require('cookie-parser'),
      bodyParser = require('body-parser'),
  
      routes = require('./routes/index'),
      users = require('./routes/users'),
  
      app = express();
  
  app
  
  // view engine setup
    .set('views', path.join(__dirname, 'views'))
    .set('view engine', 'pug')
  
  // uncomment after placing your favicon in /public
    .use(favicon(path.join(__dirname, 'public', 'favicon.ico')))
    .use(logger('dev'))
    .use(bodyParser.json())
    .use(bodyParser.urlencoded({ extended: false }))
    .use(cookieParser())
    .use(express.static(path.join(__dirname, 'public')))
  
    .use('/', routes)
    .use('/users', users)
  
  // catch 404 and forward to error handler
    .use((req, res, next) => {
      let err = new Error('Not Found');
      err.status = 404;
      next(err);
    })
  ;
  
  // error handlers
  
  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
    app.use((err, req, res, next) => {
      res.status(err.status || 500);
      res.render('error', {
        message: err.message,
        error: err
      });
    });
  }
  
  // production error handler
  // no stacktraces leaked to user
  app.use((err, req, res, next) => {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: {}
    });
  });
  
  
  module.exports = app;
  