diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | blockcypher.js | 17 | ||||
| -rw-r--r-- | cache.js | 6 | ||||
| -rw-r--r-- | config/index.js.sample | 39 | ||||
| -rw-r--r-- | db.js | 5 | ||||
| -rw-r--r-- | index.js | 26 | ||||
| -rw-r--r-- | test.js | 20 |
7 files changed, 52 insertions, 62 deletions
@@ -9,3 +9,4 @@ db config.js .env config/config.json +config/index.js diff --git a/blockcypher.js b/blockcypher.js deleted file mode 100644 index 91adbc10..00000000 --- a/blockcypher.js +++ /dev/null @@ -1,17 +0,0 @@ -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) diff --git a/cache.js b/cache.js deleted file mode 100644 index 645fd610..00000000 --- a/cache.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = (req, res, next) => { - if (req.path !== '/login') { - res.setHeader("Cache-Control", "public, max-age=900") - } - return next() -} diff --git a/config/index.js.sample b/config/index.js.sample new file mode 100644 index 00000000..d4a03230 --- /dev/null +++ b/config/index.js.sample @@ -0,0 +1,39 @@ +import db from './config.json' + +module.exports = { + db, + bitcoin: { + username: '', + password: '', + network: 'mainnet', + }, + lna: { + server: 'localhost:10001', + tls: '/home/adam/.lnd/tls.cert', + macaroon: '/home/adam/.lnd/test.macaroon', + }, + lnb: { + server: 'localhost:10002', + tls: '/home/adam/.lndb/tls.cert', + macaroon: '/home/adam/.lndb/test.macaroon', + }, + auto: { + host: "localhost", + dialect: "mysql", + tables: ["users", "payments"], + logging: false, + directory: false, + operatorsAliases: false, + dialectOptions: { + timeout: 500000, + multipleStatements: true + }, + pool: { + min: 0, + max: 25 + }, + retry: { + max: 5 + } + } +} @@ -1,4 +1,4 @@ -import config from './config/config.json' +import config from './config' import Sequelize from 'sequelize' import SequelizeAuto from 'sequelize-auto' import { resolver, defaultArgs, defaultListArgs, attributeFields } from 'graphql-sequelize' @@ -14,8 +14,7 @@ import { } from 'graphql' const Op = Sequelize.Op -const l = console.log -const conf = config[process.env.NODE_ENV] +const conf = config.db[process.env.NODE_ENV] const auto = new SequelizeAuto( conf.database, @@ -16,7 +16,7 @@ import morgan from 'morgan' import reverse from 'buffer-reverse' import zmq from 'zmq' -import cache from './cache' +import config from './config' import graphqlHTTP from 'express-graphql' @@ -24,23 +24,17 @@ dotenv.config() const l = console.log ;(async () => { - const lna = await require('lnrpc')({ server: 'localhost:10001', tls: '/home/adam/.lnd/tls.cert' }) - const maca = fs.readFileSync('/home/adam/.lnd/test.macaroon') - const meta = new grpc.Metadata() - meta.add('macaroon', maca.toString('hex')) - lna.meta = meta + const ln = async ({ server, tls, macaroon }) => { + const ln = await require('lnrpc')({ server, tls }) + ln.meta = new grpc.Metadata() + ln.meta.add('macaroon', fs.readFileSync(macaroon).toString('hex')) + return ln + } - const lnb = await require('lnrpc')({ server: 'localhost:10002', tls: '/home/adam/.lndb/tls.cert' }) - const macb = fs.readFileSync('/home/adam/.lndb/test.macaroon') - const metab = new grpc.Metadata() - metab.add('macaroon', macb.toString('hex')) - lnb.meta = metab + const lna = await ln(config.lna) + const lnb = await ln(config.lnb) - const bc = new core({ - username: 'adam', - password: 'hk79c7dI8ysAHY42eglqrJLo9A8CoyvWINMAcwuPzhQ=', - network: 'mainnet', - }) + const bc = new core(config.bitcoin) const app = express() app.enable('trust proxy') diff --git a/test.js b/test.js deleted file mode 100644 index ce3bf009..00000000 --- a/test.js +++ /dev/null @@ -1,20 +0,0 @@ -import core from 'bitcoin-core' -import fs from 'fs' -import grpc from 'grpc' - -const bc = new core({ - username: 'adam', - password: 'hk79c7dI8ysAHY42eglqrJLo9A8CoyvWINMAcwuPzhQ=', - network: 'mainnet', -}) - -;(async () => { - const lna = await require('lnrpc')({ server: 'localhost:10001', tls: '/home/adam/.lnd/tls.cert' }) - const maca = fs.readFileSync('/home/adam/.lnd/test.macaroon') - const meta = new grpc.Metadata() - meta.add('macaroon', maca.toString('hex')) - lna.meta = meta - let i = await lna.getInfo({}, meta) - console.log(i) - console.log(await bc.getBalance()) -})() |
