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

ganomede-helpers

v1.0.6

Published

Helper modules shared by ganomede microservices

Downloads

54

Readme

Ganomede Helpers

Install

Install with npm install --save ganomede-helpers

Usage

var helpers = require("ganomede-helpers");

helpers.restify.middlewares.authdb

Simplifies the integration of restify servers with authdb. Will check req.params.authToken agains passed in authdb client and fill out req.params.user with result. Replies with HTTP 400 in case of missing token; or 401 in case of error or missing account.

create: function(options)

Options:

  • authdbClient [required]: a authdb client as created using the authdb library
  • secret: allows "spoofing" req.params.user in case authToken matches ${secret}.${username} pattern. Will skip validating token and run following instead:
 req.params.user = {
   _secret: true
   username: spoofUsername // second part of token
 }
  • log: a bunyan style logger object

Returns a restify middleware function. This function requires authToken as a request parameter and fills the virtual user query parameter with the full user account details.

example

authMW = helpers.restify.middlewares.create({
  authdbClient: myClient
});
app.get "/auth/:authToken/games", authMW, getGames

helpers.links.ServiceEnv

Conveniant access to service links environment variables, compatible with docker links.

exists: function(name, port) : boolean

  • name: Name of the service to link
  • port: Default port of the service

Returns true if both the _PORT and _ADDR environemnt variables are set.

host: function(name, port) : string

  • name: Name of the service to link
  • port: Default port of the service

Returns the _ADDR environemnt variable, or 127.0.0.1

port: function(name, port) : int

  • name: Name of the service to link
  • port: Default port of the service

Returns the _PORT environemnt variable (casted to int), or the port parameter.

url: function(name, port) : string

generates and http:// URL using host and port.

example

var couch = myLib.connect(helpers.links.ServiceEnv.url('COUCH_GAMES', 5984))

helpers.Notification

Helper class allowing easier sending of notifications from ganomede services.

example

// Create notificaiton.
var notification = new helpers.Notification(
  // Fill in required fields:
  from: 'ganomede-service',
  to: 'username',
  type: 'sample-notification',
  // Fill in optional fields as neccessary:
  data: {sample: 'data'},
  secret: 'api-secret' // defaults to process.env.API_SECRET
);

// send() function bound to NOTIFICATION service address
// (set as ENV variable retrieved by ServiceEnv class).
var sendNotification = helpers.Notification.sendFn();

// Send notification.
sendNotification(notification, function (err, response) {
  // When notification is sent, it will have `id` and `timestamp`
  // set by notification service. For more details, see:
  // https://github.com/j3k0/ganomede-notifications#send-a-message-post.
});