Move require of api module to when we use it

This is a wee bit hacky - basically due to the order in which the
modules are required, we need the app to have set its settings as we
have a circular dependency.