hapi-elastic

0.3.0 • Public • Published

Elastic Search Hapi plugin

This Hapi plugin creates a single elastic client with appropriate error handling that can be used across the application,

This plugin has 100% test coverage.

Features

  • Configurable via Hapi configuration standards.
  • Single client instance.

Installation

npm install --save hapi-elastic

Usage example

var ElasticPlugin = require('hapi-elastic');
var Hapi = require('hapi');

var server = new Hapi.Server();
server.connection();

// Pass options.config to elastic client constructor
var clientOptions = { 
  config: {
    host: "http://localhost:9200" 
  }
}

server.register({ register: ElasticPlugin, options: clientOptions }, function (err) {
  //get elastic client from plugin
  var es = server.plugins['hapi-elastic'].es;
});

The options.config hash is passed to the elastic search client, for more info about possible configuration parameters please see the Elastic client configuration documentation

Package Sidebar

Install

npm i hapi-elastic

Weekly Downloads

0

Version

0.3.0

License

BSD-3-Clause

Last publish

Collaborators

  • asaf