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

@bouncingpixel/algolia

v0.5.0

Published

Helpers for algolia, namely a Mongoose model plugin

Downloads

15

Readme

algolia

Server side helpers for Algolia. Currently only has a Mongoose model plugin that extends Mongoose models for Algolia methods. For client side, just work directly with the algoliasearch package.

Working With

Requirements

  • NodeJS 6 LTS
  • An Algolia account

Free Algolia requirements

Using the Free plan on Algolia requires the use of the Powered By Logos. Use any of the logos in the freeplan-logos directory and include it with the results or on the search box. "All that we ask is a link back to Algolia via a logo next to the search bar letting the world know that your search is powered by Algolia." Download Powered By ZIP file

Configuration

This module, like many other @bouncingpixel modules, relies on nconf. The following configuration keys should be defined to use this module:

Required

  • client:algoliaAppId The ID of the app in Algolia containing all the indecies.
  • algoliaApiKey The read+write API key used on the server side. This should not be exposed to the client side.
  • client:algoliaIndexPrefix All indecies should be named with the prefix, followed by underscore, followed by the name of the data model. The prefix allows for multiple instances (dev, staging, prod, per-user etc) to share an app ID and not conflict. Algolia does not have a naming standard, but this is what we have come up with and decided to follow.

Optional

  • client:algoliaSearchKey The read only API key used on the client side. This is automatically exported to the client. This is optional if all searches are done server side. For client side, use the algoliasearch package.

Using algolia

Algolia is a 3rd party search engine that can be integrated for searching a site's data. Algolia is an optional utility that is not required, but is included as it commonly is required.

The provided Algolia integration acts as a plugin for Mongoose schemas. The plugin adds post-save hooks to automatically synchronize data with Algolia. The plugin allows a person to define which fields to listen for changes if not all fields are desired. The plugin can also automatically remove entries from Algolia when a field is set. Functions will also be added to the model to query the search index and to save or remove a data object from Algolia.

The plugin assumes each model will have a separate search index. Currently, there is no support for an index with data collected from multiple models. This functionality may be added later if there is a need for it.

To add the plugin to the schema, use the plugin method and pass any desired options for the plugin:

MySchema.plugin(require('../utils/schemas/algolia-methods'), {
  autoSave: true, // boolean if the auto-save post-save hook should be enabled
  includeObjectInIndex: fn, // a function to determine if a particular object should be included in Algolia
  castToObject: fn, // a function to convert an object into the exact data format to be stored in Algolia
  errorsOnNotFound: false, // boolean if the function findOneUpdateAndSync does not find an object to update
  updateIfAnyField: null, // an array of fields that when changed, will cause an automatic sync to Algolia
                          // the default null will assume any change should be sync'd to Algolia
  removeIfFieldSet: ['removed'] // an array of fields that when set to a truthy value will remove the object from Algolia
                                // when unset, the object will be added to Algolia
});