<commit_before>var path = require("path");

var express = require("express");
var bodyParser = require("body-parser");
var morgan = require("morgan");
var mongoose = require("mongoose");

var homeRouter = require("./routes/home");
var authRouter = require("./routes/auth");


mongoose.connect("mongodb://localhost/nodecamp");
var db = mongoose.connection;


db.once("open", function() {
  console.log("Database is connected");
});


var app = express();


app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");


app.use(express.static(path.join(__dirname, "public")));
app.use(morgan("combined"));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

app.use("/", homeRouter);
app.use("/", authRouter);


app.use(function(err, req, res, next) {
  response.status = error.status || 500;
  return response.render("error", {error: error});
});


app.listen(3000, function() {
  console.log("Server is running");
});<commit_msg>update lecture #8: fix error handling middelware<commit_after>var path = require("path");

var express = require("express");
var bodyParser = require("body-parser");
var morgan = require("morgan");
var mongoose = require("mongoose");

var homeRouter = require("./routes/home");
var authRouter = require("./routes/auth");


mongoose.connect("mongodb://localhost/nodecamp");
var db = mongoose.connection;


db.once("open", function() {
  console.log("Database is connected");
});


var app = express();


app.set("views", path.join(__dirname, "views"));
app.set("view engine", "pug");


app.use(express.static(path.join(__dirname, "public")));
app.use(morgan("combined"));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

app.use("/", homeRouter);
app.use("/", authRouter);


app.use(function(error, request, response, next) {
  response.status = error.status || 500;
  return response.render("error", {error: error});
});


app.listen(3000, function() {
  console.log("Server is running");
});
{'fraction_non_alphanumeric': 0.205, 'fraction_numerical': 0.0075, 'mean_word_length': 5.876288659793815, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2634148', 'n_tokens_mistral': 656, 'n_tokens_neox': 639, 'n_words': 136}