title: Hapi 17: Expose server properies to module registration
body: <p>We're upgrading our Hapi 16 application to Hapi 17, and Hapi-Mysql-2, and have encountered a problem with accessing server properties when a module is registered.</p>
  
  <p>Hapi-mysql-2 exposes registered database servers as <code>server.mysql.pool[x]</code> which we are exposing as <code>req.server.plugin.db.name</code> </p>
  
  <p>Whilst in most cases this way of accessing the databases is fine there are a couple of cases where we want to access the database as soon as the module is registered. However, in these cases neither <code>req</code> or <code>server</code> are avaialble.</p>
  
  <p>For example</p>
  
  <pre><code>async function loadAllGroups (mydb) {
    const sql = 'SELECT * ' +
      'FROM groups ' +
      'ORDER BY name ASC;'
    const [data] = await mydb.query(sql, [])
    return data
  }    
  
  loadAllGroups(req.server.plugins.dbs.name)
  
    .then((data) =&gt; {
      setGroups(data)
    })
  
  module.exports = new MyController()
  </code></pre>
  
  <p>In the above <code>loadAllGroups</code> is invoked as soon as the <code>mycontroller</code> is registered as a handler in my routed. In the Hapi 16 version the mysql server is not hooked to <code>server</code> so we can call it any time after it has been registered.</p>
  
  <p>Any thoughts / solutions?</p>