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

bluemix

v1.0.4

Published

Node.js helper module for IBM BlueMix

Downloads

26

Readme

bluemix

Node.js helper module for IBM BlueMix.

This module automates some common intialization tasks for Node.js applications running on IBM BlueMix. The main features of the module are:

  • parsing of common configuration enviroment variales (host, port, temporary directory)
  • parsing of VCAP services
  • search of VCAP services by name and pattern
  • automatic initialization of common services

How to Install

npm install bluemix

Example

The following sample code initializes an Express.js application and connects it to mongodb:

var bluemix = require('bluemix')
  , express = require('express')
  , app = express()

app.use(app.router);
app.use(express.errorHandler());

bluemix.on('ready', function() {
  app.listen(bluemix.config.port, bluemix.config.host);
  console.log('App started on port ' + bluemix.config.port + ' and connected to mongodb');
  
  bluemix.db.collection('test').find().toArray(function(err, data) {
    if (err) {
      // handle error
    } else {
      // work with data
    }
  });
});
bluemix.on('error', function(err) {
  console.error('App init failed', err);
});
bluemix.init(['mongodb']);

Reference

bluemix.config

The object bluemix.config is automatically initilized at startup and contains the following attributes:

  • host, hostname/address of the application
  • port, port of the application
  • tmpDir, temporary directory of the application

bluemix.getServices(name)

Returns a list of services matching name, which can be a string or a RegExp. Example:

// get an array of available mongodb-2.2 services
var a1 = bluemix.getServices('mongodb-2.2');

// get an array of mysql services, regardless of the version
var a2 = bluemix.getServices(/mysql/);

bluemix.getService(name)

Returns the first service matching name, which can be a string or a RegExp. Example:

// get the first available mongodb-2.2 service
var s1 = bluemix.getService('mongodb-2.2');

// get the first mysql service, regardless of the version
var s2 = bluemix.getService(/mysql/);

bluemix.init([dependencies])

Connects to all the available (and supported) services. The method emits a ready event upon successful connection all the services and if all the dependencies (if any) are satisfied. It emits an error event otherwise.

Supported services

The following table lists the supported services, which drivers (npm modules) are used to connect and how to access them: Service | Service name | Driver | Connected client instance --- | --- | --- | --- MongoDB | mongodb-2.2 | mongodb | bluemix.db, bluemix.mongodb RabbitMQ | rabbitmq-2.8 | amqp | bluemix.mq, bluemix.rabbitmq Mysql | mysql-5.5 | mysql | bluemix.db, bluemix.mysql Redis | redis-2.6 | redis | bluemix.redis

If both MongoDB and Mysql are defined, bluemix.db will point to the first one that was encountered. The same applies if multiple MongoDB (or Mysql) services are defined. Services can also be accessed as bluemix[service type][service name]:

bluemix['mongodb-2-2']['mongo-abcde']