npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

elastic-fortune

v0.0.2

Published

Connects Elastic Search, fortune.js & mongodb in a jiff!

Downloads

10

Readme

Extra Prerequisites

Requires: "fortune-agco": "~0.2.9", "fortune-mongodb-agco": "~0.2.4",

But they aren't direct dependencies, so they aren't listed in package.json; however you're required to be using at least those versions of those packages for compatibility with this module.

We currently also require that you use mongodb as your datastore.

Usage

#Hash of properties to related mongo collections

var collectionNameLookup = {

    "brand": "brand",

    "product_type": "product_type",

    "contract_type": "contract_type",

    "region": "region",

    "country": "country",

    "address_country": "country",

    "address_state_province": "state_province",

    "current_contracts": "contract",

    "phone_numbers": "phone_number",

    "business_hours": "business_hours",

    "current_offerings": "offering",

    "dealer_misc": "dealers_misc"
}
var Elastic_Search_URL = process.env.BONSAI_URL || "http://127.0.0.1:9200";
var Elastic_Search_Index = "dealer-api";
var type = "dealers";

#Create elastic search endpoint

var dealerSearch = new ElasticFortune(fortune_app, Elastic_Search_URL,Elastic_Search_Index, type, collectionNameLookup);
fortune_app.router.get('/dealers/search', dealerSearch.route);

#Required to make the elastic search endpoint work properly

fortune_app.setOnRouteCreated("dealer",function(route){
    dealerSearch.setFortuneRoute(route);
},this);

#Create dealer :after endpoint & sync elastic search. #Note - only 1 "after" callback is allowed per endpoint, so if you enable autosync, you're giving it up to elastic-fortune.

dealerSearch.enableAutoSync("dealer");

#Alternative way to create dealer :after endpoint & sync elastic search. This approach gives you access to do more in the after callback.

this.fortune_app.after("dealer", function (req, res, next) {
    if (req.method === 'POST' || (req.method === 'PUT' && this.id)) {
        return dealerSearch.expandAndSync(this);
    } else {
        return this;
    }
});

#If you just want to expand an object's links:

dealerSearch.expandEntity(dealer);

#If you just want to send an object to elastic search without expanding it's links:

dealerSearch.sync(this);