binance-api-node
Advanced tools
Comparing version 0.9.0 to 0.9.1
@@ -10,5 +10,5 @@ 'use strict'; | ||
var _http = require('./http'); | ||
var _httpClient = require('./http-client'); | ||
var _http2 = _interopRequireDefault(_http); | ||
var _httpClient2 = _interopRequireDefault(_httpClient); | ||
@@ -23,3 +23,3 @@ var _websocket = require('./websocket'); | ||
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return _extends({}, (0, _http2.default)(opts), { | ||
return _extends({}, (0, _httpClient2.default)(opts), { | ||
ws: (0, _websocket2.default)(opts) | ||
@@ -26,0 +26,0 @@ }); |
@@ -14,5 +14,5 @@ 'use strict'; | ||
var _http = require('./http'); | ||
var _httpClient = require('./http-client'); | ||
var _http2 = _interopRequireDefault(_http); | ||
var _httpClient2 = _interopRequireDefault(_httpClient); | ||
@@ -339,3 +339,3 @@ var _openWebsocket = require('./open-websocket'); | ||
return function (cb) { | ||
var _httpMethods = (0, _http2.default)(opts), | ||
var _httpMethods = (0, _httpClient2.default)(opts), | ||
getDataStream = _httpMethods.getDataStream, | ||
@@ -342,0 +342,0 @@ keepDataStream = _httpMethods.keepDataStream, |
{ | ||
"name": "binance-api-node", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"description": "A node API wrapper for Binance", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -1,2 +0,2 @@ | ||
import httpMethods from 'http' | ||
import httpMethods from 'http-client' | ||
import wsMethods from 'websocket' | ||
@@ -3,0 +3,0 @@ |
import zip from 'lodash.zipobject' | ||
import httpMethods from 'http' | ||
import httpMethods from 'http-client' | ||
import openWebSocket from 'open-websocket' | ||
@@ -5,0 +5,0 @@ |
@@ -5,6 +5,6 @@ import test from 'ava' | ||
import Binance, { ErrorCodes } from 'index' | ||
import { candleFields } from 'http' | ||
import { candleFields } from 'http-client' | ||
import { userEventHandler } from 'websocket' | ||
import { checkFields } from './utils' | ||
import { checkFields, createHttpServer } from './utils' | ||
@@ -131,2 +131,47 @@ dotenv.load() | ||
test('[REST] Server-side JSON error', async t => { | ||
const server = createHttpServer((req, res) => { | ||
res.statusCode = 500; | ||
res.write(JSON.stringify({ | ||
msg: 'Server unkown error', | ||
code: -1337, | ||
})) | ||
res.end() | ||
}) | ||
const localClient = Binance({ httpBase: server.url }); | ||
try { | ||
await server.start(); | ||
await localClient.ping() | ||
t.fail('did not throw'); | ||
} catch (e) { | ||
t.is(e.message, 'Server unkown error') | ||
t.is(e.code, -1337) | ||
} finally { | ||
await server.stop(); | ||
} | ||
}) | ||
test('[REST] Server-side HTML error', async t => { | ||
const serverReponse = '<html>Server Internal Error</html>' | ||
const server = createHttpServer((req, res) => { | ||
res.statusCode = 500 | ||
res.write(serverReponse) | ||
res.end() | ||
}); | ||
const localClient = Binance({ httpBase: server.url }); | ||
try { | ||
await server.start(); | ||
await localClient.ping() | ||
t.fail('did not throw'); | ||
} catch (e) { | ||
t.is(e.message, `500 Internal Server Error ${serverReponse}`) | ||
t.truthy(e.response) | ||
t.is(e.responseText, serverReponse) | ||
} finally { | ||
await server.stop(); | ||
} | ||
}) | ||
test('[WS] depth', t => { | ||
@@ -133,0 +178,0 @@ return new Promise(resolve => { |
@@ -0,1 +1,3 @@ | ||
import http from 'http'; | ||
export const checkFields = (t, object, fields) => { | ||
@@ -6,1 +8,20 @@ fields.forEach(field => { | ||
} | ||
const generatePort = (() => { | ||
let portNum = 9000; | ||
return () => portNum++; | ||
})() | ||
export const createHttpServer = (requestHandler) => { | ||
const server = http.createServer(requestHandler); | ||
const port = generatePort(); | ||
return { | ||
url: `http://127.0.0.1:${port}`, | ||
start: () => new Promise((resolve, reject) => | ||
server.listen(port, err => err ? reject(err) : resolve()) | ||
), | ||
stop: () => new Promise((resolve, reject) => | ||
server.close(err => err ? reject(err) : resolve()) | ||
), | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25
2496
105384
8