Middleware phases - initial implementation

Modify the app and router implementation, so that the middleware is
executed in order defined by phases.

Predefined phases:

    'initial', 'session', 'auth', 'parse', 'routes', 'files', 'final'

Methods defined via `app.use`, `app.route` and friends are executed
as the first thing in 'routes' phase.

API usage:

    app.middleware('initial', compression());
    app.middleware('initial:before', serveFavicon());
    app.middleware('files:after', loopback.urlNotFound());
    app.middleware('final:after', errorHandler());

Middleware flavours:

    // regular handler
    function handler(req, res, next) {
      // do stuff
      next();
    }

    // error handler
    function errorHandler(err, req, res, next) {
      // handle error and/or call next
      next(err);
    }
Merge pull request #767 from strongloop/feature/app-middleware

Middleware phases - initial implementation
package: fix deps

Move loopback-phase from "devDependencies" to "dependencies".
Merge pull request #785 from strongloop/fix/phase-dep

package: fix deps
Update chai to ^1.10.0
Fix `loopback.getCurrentContext`

 - ensure the method is always defined

 - return `null` when the context is not active
   (we are not inside a request-handling chain)
middleware/token: store the token in current ctx