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

orchestrate-mongo

v0.1.2

Published

Pipe MongoDB changes into Orchestrate.io

Downloads

15

Readme

Orchestrate-Mongo

NPM

Pipe MongoDB changes into Orchestrate.io, to effortlessly add a search, events, and relations API.

Install

npm install -g orchestrate-mongo

Usage

var OrchestrateMongo = require('orchestrate-mongo');

var importer = new OrchestrateMongo({
  orchestrate: {
    api_key: 'your_orchestrate_api_key'
  },
  mongodb: {
    port: 27017,
    host: 'localhost',
    username: 'bobross',
    password: 'happylittletrees',
    database: 'joy-of-painting'
  }
});

importer.on('change.success', console.log);

Now whenever the importer successfully writes a document to Orchestrate, it will print a message.

Using as a Daemon

You can also run Orchestrate-Mongo as a daemon, so it will continue watching your MongoDB cluster autonomously. To start the web server, just do:

npm install -g orchestrate-mongo
export ORCHESTRATE_API_KEY=...
export MONGODB_HOST=...
export MONGODB_PORT=...
export MONGODB_USERNAME=...
export MONGODB_PASSWORD=...
export MONGODB_DATABASE=...
export MONGODB_COLLECTION=...
orchestrate-mongo
# Now listening to [database]

Now the importer is running on http://localhost:3000.

Usage on Heroku

To deploy orchestrate-mongo on Heroku, you'll need the [heroku toolbelt][]. Then:

git clone [email protected]:orchestrate-io/orchestrate-mongo.git
cd orchestrate-mongo
heroku create [app-name]
heroku config:set ORCHESTRATE_API_KEY=...
heroku config:set MONGODB_HOST=...
heroku config:set MONGODB_PORT=...
heroku config:set MONGODB_USERNAME=...
heroku config:set MONGODB_PASSWORD=...
heroku config:set MONGODB_DATABASE=...
heroku config:set MONGODB_COLLECTION=...
git push heroku master

Now your app is running on Heroku! To prevent it from idling, scale the process to use two dynos:

heroku ps:scale worker=2

Options

orchestrate-mongo takes one argument, an options object. It takes the following arguments, and has the following defaults:

orchestrate: {
  api_key: process.env.ORCHESTRATE_API_KEY
},
mongodb: {
  database: process.env.MONGODB_DATABASE,
  port: process.env.MONGODB_PORT || 27017,
  host: process.env.MONGODB_HOST || 'localhost',
  dbOpts: {
    w: 1
  },
  format: 'raw',
  convertObjectIDs: true,
  onError: function (error) {
    console.log('Error - MongoWatch:', (error && error.stack) || error)
  },
  onDebug: function () {},
  username: process.env.MONGODB_USERNAME,
  password: process.env.MONGODB_PASSWORD
},
collection: process.env.MONGODB_COLLECTION

You can set many of these options as environment variables, or you can pass them directly:

var OrchestrateMongo = require('orchestrate-mongo');

var importer = new OrchestrateMongo({
  orchestrate: {
    api_key: 'your_orchestrate_api_key'
  },
  mongodb: {
    port: 27017,
    host: 'localhost',
    username: 'bobross',
    password: 'happylittletrees'
  }
});

Events

  • connect
  • change: Emitted whenever processing a change starts, succeeded, and errors out.
  • change.start: Detected a change in MongoDB.
  • change.success: Writing a document to Orchestrate.io succeeded!
  • change.error: Writing a document to Orchestrate.io failed due to an error.
  • error: The connection to MongoDB experienced an error.
  • drain: The queue has run out of changes to process.

Tests

First, start MongoDB like this:

sudo mongod --replSet someArbitraryName

Then, in the mongo console, run this:

rs.initiate()

Then, set your environment variables:

export MONGODB_COLLECTION=update_operators
export MONGODB_DATABASE=orchestrate-mongodb
export ORCHESTRATE_API_KEY=YOUR_ORCHESTRATE_API_KEY

And finally, run your tests!

npm test

License

ISC, yo.