strongloop/loopback — pull request #790 by bajtos (2014-11-12 08:05:17+00:00)
Title: Simplify `app.defineMiddlewarePhases`

Refactor the implementation to use the new method `phaseList.zipMerge`.

This is commit is changing the behaviour in the case when
the first new phase does not exist in the current list.

Before the change, all new phases were added just before the "routes"
phase.

After this change, new phases are added to the head of the list,
until an existing phase is encountered, at which point the regular
merge algorithm kicks in.

Example:

app.defineMiddlewarePhases(['first', 'routes', 'subapps']);

Before the change: code throws an error - 'routes' already exists.

After the change: phases are merged with the following result:

'first', 'initial', ..., 'routes', 'subapps', ...

This PR is a follow-up for #786, it requires https://github.com/strongloop/loopback-phase/pull/7

/to @ritch please review
/cc @raymondfeng