LevelDB Based User Registry For NodeJS
JavaScript
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
.npmignore
README.md
index.js
package.json

README.md

userbook

LevelDB Based User Registry For NodeJS

Install

$ npm install userbook

Usage

Creating a user:

var users = require('userbook')('./data-users')

users.create({ email: 'foo@bar.com', password: 123456 }, function (error, user) {

  user.authkey
  // => a3B21c

})

Login with username and password:

users.login({ email: 'foo@bar.com', password: 123456 }, function (error, record) {

  record.authkey
  // => a3B21c

})

Login with username and authkey:

users.login({ email: 'foo@bar.com', authkey: 'a3B21c' }, function (error, record) {

  record.email
  // => foo@bar.com

  record.authkey
  // => a3B21c

})

To just read a record:

users.read('foo@bar.com', function (error, user) {
  user.authkey
  // => a1B23d
})

Extending

Adding new fields to the user model is easy:

users = require('userbook')('./data-users', {
  username: { is: String, required: true, allowed: ['a-z', '0-9', '-', '_'], len: [1, 24] },
  age: Number
})

The reference of field options is at github.com/azer/checkfor

More Info

  • See test/custom-index.js for customizing indexes.
  • See test/io.js for reusing existing LevelDB client in userbook.
  • See test/prefix.js for changing key prefixes from users: to something else.