title: Cannot read property 'on' of undefined : Error in Keystone.js
body: <p>I have been following the tutorial at <a href="https://leanpub.com/keystonejs/read" rel="nofollow noreferrer">https://leanpub.com/keystonejs/read</a> and trying to set up a basic website.</p>
  
  <p>For this wanted to build a route for <code>/</code> with a view file <code>index.js</code> and template at `index.twig'</p>
  
  <p>The following is the directory structure</p>
  
  <pre><code>routes/
  |-- index.js
  |-- middleware.js
  `-- views
      |-- blog.js
      |-- contact.js
      |-- gallery.js
      |-- index.js
      `-- post.js
  templates/
  |-- layouts
  |   `-- default.twig
  |-- mixins
  |   `-- flash-messages.twig
  `-- views
      |-- assets -&gt; public/assets/
      |-- blog.twig
      |-- contact.twig
      |-- errors
      |   |-- 404.twig
      |   `-- 500.twig
      |-- gallery.twig
      |-- index.html -&gt; templates/views/index.twig
      |-- index.twig
      |-- post.twig
  models/
  |-- Audience.js
  |-- Element.js
  |-- Enquiry.js
  |-- Gallery.js
  |-- Guide.js
  |-- Post.js
  |-- PostCategory.js
  |-- Section.js
  |-- Subsection.js
  `-- User.js
  </code></pre>
  
  <p>Following are my <code>keystone.js</code>, <code>routes/index.js</code> and <code>routes/views/index.js</code> files.</p>
  
  <pre><code>    // Simulate config options from your production environment by
  // customising the .env file in your project's root folder.
  require('dotenv').config();
  
  // Require keystone
  var keystone = require('keystone');
  var Twig = require('twig');
  
  // Initialise Keystone with your project's configuration.
  // See http://keystonejs.com/guide/config for available options
  // and documentation.
  
  keystone.init({
      'name': 'Bodhini',
      'brand': 'Bodhini',
  
      'less': 'public',
      'static': 'public',
      'favicon': 'public/favicon.ico',
      'views': 'templates/views',
      'view engine': 'twig',
  
      'twig options': { method: 'fs' },
      'custom engine': Twig.render,
  
      'auto update': true,
      'session': true,
      'auth': true,
      'user model': 'User',
  });
  
  // Load your project's Models
  keystone.import('models');
  
  // Setup common locals for your templates. The following are required for the
  // bundled templates and layouts. Any runtime locals (that should be set uniquely
  // for each request) should be added to ./routes/middleware.js
  keystone.set('locals', {
      _: require('lodash'),
      env: keystone.get('env'),
      utils: keystone.utils,
      editable: keystone.content.editable,
  });
  
      // Load your project's Routes
      keystone.set('routes', require('./routes'));
  
  
      // Configure the navigation bar in Keystone's Admin UI
      keystone.set('nav', {
      posts: ['posts', 'post-categories'],
      galleries: 'galleries',
      enquiries: 'enquiries',
      users: 'users',
      Guide: ['guides','sections','subsections','audiences'],
      element:'elements',});
      // Start Keystone to connect to your database and initialise the web server
  </code></pre>
  
  <p><strong>routes/index.js</strong></p>
  
  <pre><code>var keystone = require('keystone');
  var middleware = require('./middleware');
  var importRoutes = keystone.importer(__dirname);
  
  // Common Middleware
  keystone.pre('routes', middleware.initLocals);
  keystone.pre('render', middleware.flashMessages);
  
  // Import Route Controllers
  var routes = {
      views: importRoutes('./views'),
  };
  
  // Setup Route Bindings
  exports = module.exports = function (app) {
      // Views
      app.get('/', routes.views.index);
      app.get('/blog/:category?', routes.views.blog);
      app.get('/blog/post/:post', routes.views.post);
      app.get('/gallery', routes.views.gallery);
      app.all('/contact', routes.views.contact);
  
      // NOTE: To protect a route so that only admins can see it, use the requireUser middleware:
      // app.get('/protected', middleware.requireUser, routes.views.protected);
  
  };
  </code></pre>
  
  <p><strong>routes/views/index.js</strong></p>
  
  <pre><code>var keystone = require('keystone');
  
  exports = module.exports = function(req, res){
      var view = keystone.View(req, res);
      var locals = res.locals;
  
      locals.data={
          story:{},
          work:{},
          why:{},
          disclaimer:{},
      };
  
  
      view.on('init', function(next){
      var q = kestone.list('Element').model.findOne({slug: 'story'});
          q.exec(function(err, result){
          locals.data.story = result;
              next(err);
  
          });
  
      });
  
      view.render('index');
  </code></pre>
  
  <p>While I run <code>node keystone</code> and then try opening path <code>/</code> in browser, I get a 404 error along with this output.</p>
  
  <pre><code>------------------------------------------------
  KeystoneJS Started:
  Bodhini is ready on http://0.0.0.0:3000
  ------------------------------------------------
  
  Error thrown for request: /
  TypeError: Cannot read property 'on' of undefined
      at module.exports (/home/auditor/Sites/Bodhini/routes/views/index.js:35:9)
      at Layer.handle [as handle_request] (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/layer.js:95:5)
      at next (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/route.js:131:13)
      at Route.dispatch (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/route.js:112:3)
      at Layer.handle [as handle_request] (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/layer.js:95:5)
      at /home/auditor/Sites/Bodhini/node_modules/express/lib/router/index.js:277:22
      at Function.process_params (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/index.js:330:12)
      at next (/home/auditor/Sites/Bodhini/node_modules/express/lib/router/index.js:271:10)
      at /home/auditor/Sites/Bodhini/node_modules/grappling-hook/index.js:198:10
      at _combinedTickCallback (internal/process/next_tick.js:95:7)
      at process._tickCallback (internal/process/next_tick.js:161:9)
  GET / 500 16.644 ms
  </code></pre>
  
  <p>Please guide me on how to fix this. I am new to node.js and express/keystone</p>