Feature: Master Page

As a vision user
I want the vision application served as a single page
So that I can spend less time waiting for page loads

Let's add a test to ./test/home.js for our feature Master Page. This resource will GET our master page from route ./ and return a 200 OK response. The Content-Type of the response should be HTML:

   var app = require('../app')
 , request = require('supertest'),

describe('vision master page', function(){
  describe('when requesting resource /', function(){
    it('should respond with view', function(done){
      request(app)
        .get('/')
        .expect('Content-Type', /html/)
        .expect(200, done)
    });
  });
});

Let's implement our Master Page feature. Let's create a new module that exposes a route ./lib/routes/home.js and add a new index function. We start by defining a route called index. We create a view model with meta information for a page and then render the view passing the view model:

exports.index = function(req, res){
  var model = {
    title: 'vision.',
    description: 'a project based dashboard for github',
    author: 'airasoul',
     user: 'Andrew Keig'
  };
  res.render('index', model);
};

Let's add a new route to our Express server ./lib/express/index.js:

app.get('/', routes.home.index);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.137.169