merlin.js

1.4.0 • Public • Published

Merlin JavaScript Library

This is the JavaScript library for Merlin Search.

Installation

node (also browserify/webpack compatible)

npm install merlin.js
var Blackbird = require('merlin.js');

Browser

<script src="merlin.browser.min.js"></script>

Usage

For usage examples, see the Search API documentation.

var engine = Blackbird.engine({
    company: 'company_name',
    environment: 'environment_name', 
    instance: 'instance_name'
});
 
// promise style API
engine.search({ q: 'dress' })
.then(function (res) { 
    console.log(res.body.results.numfound);
})
.catch(function (err) {
    console.error('Oh no!');
});

Fallback

Fallback handles requests that fail for a given reason, such as CORS being disabled by a firewall. Currently the only supported fallback mode is proxy.

Pass the following in as a fallback in the Blackbird.engine call to enable falling back to a proxy. Note that fallback is only enabled when using merlin.js in a client environment (browser).

    fallback: {
        mode: 'proxy',
        url: 'http://your_proxy.com' // will fallback to this URL if requests fail
    }

Enabling falling back to a proxy will make it so the engine does the following:

  1. Make a request (eg. https://search.blackbird.am/company_name.environment_name.instance_name?q=dress)
  2. If request or response is rejected, prepend proxy url to request URL (http://your_proxy.com/https://search.blackbird.am/company_name.environment_name.instance_name?q=dress) and make a request.
  3. Set it so that the engine uses the proxy going forward (for that session).

Development

Clone the repo, then run the following:

cd merlin.js
npm install

Build

Building compiles the webpacked files into dist/

npm run build

Running the tests (mocha)

npm test

Documentation

Readme

Keywords

Package Sidebar

Install

npm i merlin.js

Weekly Downloads

1

Version

1.4.0

License

Apache-2.0

Last publish

Collaborators

  • daviskim