Use a middleware function for middleware config

Rather than exporting an object which then has to be added to app.locals
manually we simply export the middleware config as another piece of
middlware, which can then augments app.locals itself.

This has the added benefit of being able to do further configuration
beyond template locals if necessary.

I've also taken this opportunity to remove the dependency on the
'version' module, which was only being used here.
Move duplicated locals into config middleware
Move template config into a separate module

This configuration is duplicated between the hosting and instance apps,
so it makes sense to move it all into one place.
Make route middleware an actual piece of middleware