How to access app object from a module in ExpressJS?

I run an Express app like this inside app.js file:

var app = express();

Now I can set some variables like this:

app.set('host', 'myhost')

I also have api.js module and I want to access this host variable from the root app.js file. How can I do this?

In your app.js file:

module.exports = app;

In your api.js file:

app = require("./app.js")
host = app.get('host');