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

rolodex

v0.17.0

Published

Node account management system using redis

Downloads

9

Readme

rolodex

Instalation

I always recomend you bundle your dependencies with your application. To do this, create a package.json file in the root of your project with the minimum information...

{
  "name": "yourapplication",
  "version": "0.1.0",
  "dependencies": {
    "rolodex": "0.8.0"
  }
}

Then run the following command using npm...

npm install

OR, if you just want to start playing with the library run...

npm install rolodex

Docs

To create a rolodex object that gives us user management functions we must pass in a configuration object.

var rolodex = require("rolodex")(config)

Configuration

Rolodex can run in two different modes. master and slave.

Example of master configuration object...

{
  "role": "master",
  "email": {
    "postmark": "dc2d8r99-771e-4d6f-95b8-3403e1bd5poi",
    "defaults": {
      "from"    : "[email protected]",
      "reply_to": "[email protected]"
    }
  },
  "redis": {
    ...
  }
}

Example of master configuration object...

{
  "role": "slave",
  "master": {
    ...
  }
}

Errors

Anytime errors are accepted as the first argument of the callback it will return null if the request was successful and if there are validation errors it will look like the following...

{
  messages: [
    "Email must be unique"
    "Password confirmation must match"
  ],
  details: {
    "email": "must be unique"
    "password": "confirmation must match"
  }
}

Account

Account Object looks like the following...

{
  id: 'ojzg-su2w-kqsn',
  uuid: 'b902b494-3392-4499-958b-2698b8ae411e',
  email: '[email protected]',
  email_verified_at: '2011-09-23T02:17:26.229Z',
  updated_at: '2011-09-23T02:17:26.229Z',
  created_at: '2011-09-23T02:17:26.228Z'
}

The account object gives you two basic functions set and get. The

account.set([identifier,] props, callback)

You are to provide an identifier if you wish to update the record. Otherwise rolodex will assume a new record is being created.

There are two ways to create an account.

  1. Pass in email_verified property with the value true. This is when authentication has been done with a third party service such as Mozilla's Persona.

    var validAccount = { "email": "[email protected]", "email_verified": true }

  2. The other option is to pass in password and password_confirmation properties. When this is the case, email will assume to be unverified.

    var validAccount = { "email": "[email protected]", "password": "secret", "password_confirmation": "secret" }

The set command with either object will create an account.

rolodex.account.set(validAccount, function(errors, account){
  console.log(account)
})

account.get(identifier, callback)

rolodex.account.get("ojzg-su2w-kqsn", function(account){
  console.log(account)
})

The following are possible values for identifier.

  • account id (String). eg "ojzg-su2w-kgsn"
  • uuid key value pair (Object). eg { uuid: "fdc7af2d-f3c2-4475-bb1c-7a17caed3564"}
  • email key value pair (Object). eg { email: "[email protected]"}

eg. (find by params other than id)

rolodex.account.get({ "email": "brock@sintaxi" }, function(account){
  console.log(account)
})

account.validate([identifier,] object, callback)

Validate is very similar to the set method except that it does not write to the store.

rolodex.account.validate({}, function(errors, account){
  console.log(errors)
})

account.email(callback)

Emails a user if a record is found in the system

rolodex.account.email({ "uuid": "fdc7af2d-f3c2-4475-bb1c-7a17caed3564" }, function(errors, message){
  console.log(message)
})

account.all(callback)

Gets all accounts

rolodex.account.all(function(accounts){
  console.log(accounts)
})

account.group(role, callback)

Returns all records that match that role.

rolodex.account.group(3, function(accounts){
  console.log(accounts)
})

account.authenticate(identifier, password, callback)

Authenticates the account. If successful, the account will be returned.

rolodex.account.authenticate({ email: "[email protected]" }, "secret", function(errors, account){
  console.log(account)
})

Roles

Roles are arbitrary but this is the line of thinking when creating this lib.

0 - Owners
1 - Admin
2 - Dev
3 - Employee
4 - Mod
5 - Customer

License

Copyright 2011/2012 Chloi Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.