geis

0.1.0 • Public • Published

Geis

Build Status Documentation

npm install geis

A RethinkDB backed distributed lock.

import Geis from "geis"

Geis.create("user:emails").then( lock => {
  // tell the world!
  this.emit("lock", lock)
})

// somewhere else
lock.synchronize( done => {
  Users.count({ email : req.body.email }).then( n => {
    if (n > 0) {
      res.status(400).json({ error: "this email is already registered for an account" })
      return done()
    }
    // transparently handles promises to allow for flatter code structures
    return User.create({ email : req.body.email }).then( user => {
      res.json({ message : "successfully registered!" })
    }).catch( err => {
      res.status(500).message({ error: err.message })
    })
  })
})

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.0
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.0
    1
  • 0.0.1
    0

Package Sidebar

Install

npm i geis

Weekly Downloads

1

Version

0.1.0

License

ISC

Last publish

Collaborators

  • ondreian