strongloop/loopback — pull request #786 by bajtos (2014-11-11 16:18:10+00:00)
Title: Implement `app.defineMiddlewarePhases`

Implement method for registering (new) middleware phases.

- If all names are new, then the phases are added just before
the "routes" phase.

- Otherwise the provided list of names is merged with the existing
phases in such way that the order of phases is preserved.

Example

// built-in phases:
// initial, session, auth, parse, routes, files, final

app.defineMiddlewarePhases('custom');
// new list of phases
// initial, session, auth, parse,
// custom,
// routes, files, final

app.defineMiddlewarePhases([
'initial', 'postinit', 'preauth', 'routes', 'subapps'
]);
// new list of phases
// initial,
// postinit, preauth,
// session, auth, parse, custom,
// routes,
// subapps,
// files, final

A part of #739

/to @ritch please review
/cc @raymondfeng