aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/createProviderMiddleware.js
blob: 8a939ba4ef80c3fa2e086a42f82783d3f3ccd1c5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
module.exports = createProviderMiddleware

/**
 * Forwards an HTTP request to the current Web3 provider
 *
 * @param {{ provider: Object }} config Configuration containing current Web3 provider
 */
function createProviderMiddleware ({ provider }) {
  return (req, res, next, end) => {
    provider.sendAsync(req, (err, _res) => {
      if (err) return end(err)
      res.result = _res.result
      end()
    })
  }
}