Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nodefony/elastic-bundle

Package Overview
Dependencies
Maintainers
1
Versions
95
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nodefony/elastic-bundle

Nodefony Framework Bundle elasticsearch

  • 5.0.4
  • npm
  • Socket score

Version published
Weekly downloads
39
increased by2.63%
Maintainers
1
Weekly downloads
 
Created
Source

Welcome to elastic-bundle

Register and Configure elastic Bundle

For a Register elastic-bundle add elastic: true in config framework

./config/config.js
module.exports = {
  system: {
    /**
    * BUNDLES CORE
    */
    elastic: true
  }
}

Override elastic-bundle configuration your bundle

./app/config/config.js
/**
 * OVERRIDE ELASTIC BUNDLE SETTINGS
 *   elasticsearch
 *
 *	 options  :  https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html
 *
 */
"elastic-bundle": {
  elasticsearch: {
    globalHostsOptions: {
      protocol: "http"
    },
    globalOptions: {
      ssl: {
        //key : path.resolve("config","certificates","server","privkey.pem"),
        //cert : path.resolve("config","certificates","server","cert.pem"),
        //ca : path.resolve("config","certificates","ca","nodefony-root-ca.crt.pem")
      }
    },
    connections: {
      main: {
        hosts: [{
          host: "192.168.100.181",
          port: 9200
        }],
        sniffOnStart: true,
        sniffInterval: 5000
      }
    }
  }
}

Example to use :

./controller/defaultController.js
/**
 *    @Route ("/elastic")
 * 		https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html
 */
module.exports = class defaultController extends nodefony.controller {

  constructor(container, context) {
    super(container, context);
    this.client = this.get("elastic").getClient("main");
  }

  health(params = {}) {
    return this.client.cluster.health(params);
  }

  create() {
    return this.client.indices.create({
      index: 'nodefony'
    });
  }

  ping() {
    return this.client.ping({
      requestTimeout: 30000,
    });
  }

  /**
   *    @Method ({"GET"})
   *    @Route (name="elastic-index")
   *
   */
  indexAction() {
    return this.ping()
      .then(this.health.bind(this))

      .then((ele) => {
        return this.render("cci-bundle::index.html.twig", {
          name: `Elastic Ping : ${ele}`
        }).catch((e) => {
          throw e;
        });
      }).catch((e) => {
        throw e;
      });
  }
};

Authors

License

Keywords

FAQs

Package last updated on 26 Aug 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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