Maki-Sushi
Intro
Maki-Sushi is a Neo4J REST API wrapper (hence the name), which allows you to call the API in simple, comprehensible code.
It was developped by Jo Colina @jsmrcaga to use with Graphr, a simple graph viewer.
Installation
You can install maki-sushi globally or locally like so:
Locally:
npm install maki-sushi
Global:
npm install maki-sushi -g
Usage
var maki = ;
We will be using maki
in the rest of the documentation to reference an instance of maki-sushi.
Config
Different methods allow you to configure Maki-Sushi, however, most of them are used by maki-sushi internal functions, which you can use to simplify your code. You can use these configuration functions if you need to make custom requests to your Neo4j server.
setEndpoint(host, path)
This function overrides the default host: localhost
and path /db/data
.
Only to use if you have configured your Neo4J server to listen in a different endpoint.
setPort(port)
This function overrides the default port 7474
. Only to use if you have configured your Neo4J server to listen on a different port.
setId(user, password)
This function sets your IDs in need of authentication. In Neo4J auth is treated with a simple HTTP header in base 64
setPath(path)
This function appends the path to the base path endpoint. Eg: setPath("/transaction")
returns "/db/data/transaction"
setMethod(method)
Sets the HTTP method to use in query: GET, POST, DELETE, PUT.
setHeaders(headers)
Set headers to send with request. Must be defined as JSON:
"Content-Type": "application/json" "headerX" : "valueX"
Callbacks
Every function called by maki requires a callback. Each callback is given the status code of the response (as Neo4J uses very different statuses for responses) and the corresponding response in a JSON string.
Your callbacks must then be as follows:
{ ifstatus > 400 // typically error return; ;}
Nodes
Simple node manipulations functions.
create(properties, callback)
This method, called as: maki.nodes.create(properties, callback)
creates a node in Neo4J with the given properties. Properties are sent as a javascript Object Literal. EG:
makinodes;