New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cypher-stream

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypher-stream - npm Package Compare versions

Comparing version 0.1.9 to 0.1.10

40

index.js
var oboe = require('oboe');
var Readable = require('stream').Readable;
var util = require('util');
var urlParser = require('url');

@@ -27,21 +28,35 @@ util.inherits(CypherStream, Readable);

function CypherStream (url, query, params) {
function CypherStream (url, statement, parameters) {
Readable.call(this, { objectMode: true });
var columns;
var stream = this;
var headers = {
"X-Stream": true,
"Accept": "application/json",
};
var parsedUrl = urlParser.parse(url);
//add HTTP basic auth if needed
if(parsedUrl.auth) {
headers['Authorization'] = 'Basic ' +
new Buffer(parsedUrl.auth).toString('base64');
}
if (url[url.length - 1] !== '/') {
url += '/'; // ensure trailing slash
}
oboe({
url : url+'db/data/cypher',
url : url+'db/data/transaction/commit',
method : 'POST',
headers : headers,
headers : { "X-Stream": true, "Accept": "application/json" },
body : { query: query, params: params }
body : { statements: [ { statement: statement, parameters: parameters} ] }
})
.node('!columns', function CypherStreamNodeColumns(c) {
.node('!results[*].columns', function CypherStreamNodeColumns(c) {
stream.emit('columns', c);
columns = c;
this.forget();
})
.node('!data[*]', function CypherStreamNodeData(result, path, ancestors) {
.node('!results[*].data[*].row', function CypherStreamNodeData(result, path, ancestors) {
var data = {};

@@ -56,2 +71,11 @@ columns.forEach(function (column, i) {

})
.node('!errors[*]', function (error, path, ancestors){
var message = "Query Failure";
if(error.message) {
message += ": " + error.message;
}
var err = new Error(message);
err.code = error.code;
stream.emit('error', err);
})
.fail(function CypherStreamHandleError(error) {

@@ -62,4 +86,4 @@ // handle non-neo4j errors

var err = error.thrown || new Error('Neo4j ' + error.statusCode);
err.statusCode = error.statusCode
err.body = error.body
err.statusCode = error.statusCode;
err.body = error.body;
err.jsonBody = error.jsonBody;

@@ -66,0 +90,0 @@ stream.emit('error', err);

4

package.json
{
"name": "cypher-stream",
"version": "0.1.9",
"version": "0.1.10",
"description": "Streams cypher query results in a clean format",

@@ -25,3 +25,3 @@ "main": "index.js",

"dependencies": {
"oboe": "~1.15.0"
"oboe": "~2.0.2"
},

@@ -28,0 +28,0 @@ "devDependencies": {

@@ -0,0 +0,0 @@ # cypher-stream [![Build Status](https://travis-ci.org/brian-gates/cypher-stream.png?branch=master)](https://travis-ci.org/brian-gates/cypher-stream) [![NPM version](https://badge.fury.io/js/cypher-stream.png)](http://badge.fury.io/js/cypher-stream) [![devDependency Status](https://david-dm.org/brian-gates/cypher-stream.png?theme=shields.io)](https://david-dm.org/brian-gates/cypher-stream.png#info=devDependencies)

@@ -26,3 +26,3 @@ var should = require('should');

cypher('match (n:Test) return n limit 10')
.on('data', function (result){
.on('data', function (result) {
results++;

@@ -45,6 +45,7 @@ result.should.eql({ n: { test: true } });

errored = true;
String(error).should.equal('Error: Query failure: Invalid input \'i\': expected <init> (line 1, column 1)\n"invalid query"\n ^');
error.neo4j.exception.should.equal('SyntaxException');
error.neo4j.stacktrace.should.be.an.array;
error.neo4j.statusCode.should.equal(400);
String(error).should.equal('Error: Query Failure: Invalid input \'i\': expected <init> (line 1, column 1)\n"invalid query"\n ^');
// these aren't returned the same in transaction mode.
// error.neo4j.exception.should.equal('SyntaxException');
// error.neo4j.stacktrace.should.be.an.array;
// error.neo4j.statusCode.should.equal(400);
})

@@ -138,2 +139,11 @@ .on('end', function() {

it('works with basic http auth', function (done){
var cyp = require('../index')('http://neo:cypher@localhost:7474/');
cyp('match (n:Test) return n limit 1')
.on('error', shouldNotError)
.on('end', done)
.resume()
;
});
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc