text: var express = require("express");
  var logger = require("morgan");
  var path = require("path");
  
  // Root Express App
  // ----------------
  
  var app = express();
  app.set("views", path.join(__dirname, "views"));
  app.set("view engine", "jade");
  app.use(logger("dev"));
  
  // Resource Not Found
  // ------------------
  
  app.use(function(req, res, next) {
    var err = new Error("Not Found");
    err.status = 404;
    next(err);
  });
  
  // Global Error Handlers
  // ---------------------
  
  // development error handler: will print stacktrace
  if (app.get("env") === "development") {
    app.use(function(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(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render("error", {
      message: err.message,
      error: {}
    });
  });
  
  // Exports
  // -------
  
  module.exports = app;
  