No description, website, or topics provided.
JavaScript Shell HTML
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
build
src
test
.babelrc
.gitignore
.npmignore
.travis.yml
LICENSE.txt
README.md
karma.conf.js
package.json
tests.webpack.js
webpack.config.babel.js

README.md

gc-ajax-plugin is a gremlin-console plugin that loads an http page rather than connecting directly to gremlin-server via websockets. This allows users to handle authentication and authorization on the server end.

Build Status Coverage Status npm GitHub license

Install

npm install gc-ajax-plugin

Getting started

Using ES2015/2016
import GremlinConsole from 'gremlin-console';
import GCAjaxPlugin from 'gc-ajax-plugin';

//create a console + input combo by passing css selectors to GremlinConsole
//Load http://localhost:80/my/path
const gc = GremlinConsole('#console-window', '#console-input' {
    host:"http://localhost",
    port: 80,
    driverOptions: {path: "/my/path"}
});
gc.register(GCAjaxPlugin()); //register the plugin
In browser

It is not recomended that you do this as this is relatively heavy. gremlin-console and gc-ajax-plugin will contain duplicate dependencies (though they shouldn't conflict). However it is a possible use case.

<head>
  <!-- ... -->
  <link rel="stylesheet" type="text/css" href="umd/css/default.css">
  <script src="path-to-umd/gremlin-console.min.js"></script>
  <script src="path-to-umd/gc-ajax-plugin.min.js"></script>
</head>
//create a console + input combo by passing css selectors to GremlinConsole
//Load http://localhost:80/my/path
var gc = GremlinConsole.create('#console-window', '#console-input' {
    host:"http://localhost",
    port: 80,
    driverOptions: {path: "/my/path"}
});
gc.register(GCAjaxPlugin.init()); //register the plugin

Server side requirements

It is the User's responsibility to set up the appropriate web page for the console to connect to. You can do any Authentication or Authorization you may require here.

In the examples above the console will send POST requests to http://localhost:80/my/path. These requests will provide the following form data :

  • gremlin : a string containing the gremlin query.
  • bindings : an array containing bindings for the query. You can pretty much ignore this unless you are doing some really low level calls against the Console API

In return the console expects to receive a gremlin-server response (GraphSON format) as a string (full result, no streaming supported at the moment).

Note: It may be required for you to set the following header for your response: Access-Control-Allow-Origin: *.

Advanced

You can use this plugin along side other plugins (such as the text output plugin). Just be wary of the registration order. You'll want to register this plugin before the others