var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var app = express();

var mongoskin = require('mongoskin');
var dbUrl = process.env.MONGO_URL || 'mongodb://192.168.99.100:27017/blog';
var db = mongoskin.db(dbUrl, {
  safe: true
});
var collections = {
  users: db.collection('users'),
  articles: db.collection('articles')
};

app.locals.title = 'blog-express';

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));


// Page & REST API Routes
require('./routes')(app);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
  var 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(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: {}
  });
});


module.exports = app;

@@ -938,16 +938,289 @@
 c')));%0A%0A
+// TODO%0A// %E5%85%A8%E3%83%AA%E3%82%AF%E3%82%A8%E3%82%B9%E3%83%88%E3%81%AE%E3%81%9F%E3%81%B3%E3%81%ABmondodb%E3%81%AE%E4%B8%AD%E8%BA%AB%E3%82%92%E3%83%81%E3%82%A7%E3%83%83%E3%82%AF%E3%81%97%E3%81%A6%E3%81%84%E3%82%8B%E3%81%91%E3%81%A9%0A// %E3%81%93%E3%81%93%E3%81%A7%E3%82%84%E3%82%8B%E3%81%B9%E3%81%8D%E3%81%8B%E3%81%AF%E5%86%8D%E8%80%83%E3%81%AE%E4%BD%99%E5%9C%B0%E3%81%82%E3%82%8A%0A// %E3%81%A8%E3%81%84%E3%81%86%E3%81%8B%E5%8B%95%E4%BD%9C%E3%81%97%E3%81%A6%E3%81%AA%E3%81%84%EF%BC%81%EF%BC%9F%0Aapp.use(function(req, res, next) %7B%0A  if(!collections.articles %7C%7C !collections.users) %7B%0A    return next(new Error('No collections :('));%0A  %7D%0A  req.collections = collections;%0A  return next();%0A%7D);%0A
 %0A// Page

Add 取得したデータをreq.collectionsにアタッチするようにした