aboutsummaryrefslogtreecommitdiffstats
path: root/blockcypher.js
blob: 91adbc10cd6736b962b74b60aba6a93b3bd02305 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const proxyMiddleware = require('http-proxy-middleware')
const proxyContext = '/blockcypher'

const proxyOptions = {
  target: 'https://api.blockcypher.com',
  changeOrigin: true,
  pathRewrite: {
    '^/blockcypher/': '/'
  },
  onProxyReq: function(proxyReq, req, res) {
    var symbol
    symbol = indexOf.call(proxyReq.path, '?') >= 0 ? '&' : '?'
    return proxyReq.path += symbol + "token=" + config.blockcypher_token
  }
}

module.exports = proxyMiddleware(proxyContext, proxyOptions)