Rejigger index.js to isolate buildMenu function

Created two functions, intercept() and buildMenu(), so that each request
that comes through the macondo middleware can iterate over buildMenu for
all models configured as hasMenu=true, and then passing off to intercept
to test whether the route should be handled by macondo or passed to
next().

The iteration is self-contained in buildMenu, requiring only one
variable i to be defined outside of the function to facilitate
asynchronous iteration.