title: How to return a promise to serverless-http
body: <p>Im attempting to use <a href="https://github.com/dougmoscrop/serverless-http" rel="nofollow noreferrer">serverless-http</a> to deploy an express application to AWS lambda. But my application requires a call to an <code>init()</code> function that loads the routes among other things and then returns a promise. </p>
  
  <pre><code>const serverless = require('serverless-http');
  const Core = require('./core')
  
  module.exports.handler = Core.init(process.cwd())
  .then(Core =&gt; serverless(Core.Server))
  .catch(err =&gt; console.log(err))
  </code></pre>
  
  <p>The issue is that serverless-http needs <code>module.exports.handler</code> to be assigned to the <code>serverless</code> function call and not the promise.</p>
  
  <p>I have also tried this</p>
  
  <pre><code>const Core = require('./core')
  
  Core.init(process.cwd())
  .then(Core =&gt; module.exports.handler = serverless(Core.Server))
  .catch(err =&gt; console.log(err))
  </code></pre>
  
  <p>but it makes sense that that doesn't work either. </p>