Running an async function before express.js start
<p>I want to run an async operation (for example, wait for a URL call to complete) before I start my app. I don't know how to do that (since it's an upper-level application - no async/await here).</p>

<p>www.js:</p>

<pre><code>var app = require('./app');
var http = require('http');
const port = '3000';
app.set('port', port);
var server = http.createServer(app);
server.listen(port);
</code></pre>

<p>app.js:</p>

<pre><code>var express = require('express');
var app = express();
var Promise = require('bluebird');

# HERE IS WHERE I WANT TO "AWAIT" AN ASYNCHRONOUS CALL. 
# I KNOW I CAN'T USE AWAIT BECAUSE I'M NOT WITHIN 
# AN "ASYNC" ANNOTATED FUNCTION. EXAMPLE:
const data = await Promise.promisify(fs.readFile('DATA'));

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
module.exports = app;
</code></pre>

<p>I thought about wrapping all of <code>app.js</code> with a Promise.promisify() so I can use async await withing it. But I'm not sure how that would be handled in <code>www.js</code>, since it is not invoked, as in <code>app()</code> but passed on to <code>http.createServer</code></p>