Hey all, good evening from Tokyo.

I've been working on a REST API facelift recently for a client, and
extracted out what I learned into a library.

It's called Sajak: Simple Authenticated JSON API Kit.

It's a zero-dependency (but Express/Connect compatible) module in ~270
LOC that turns a collection of model constructors into an http
listener that handles HATEOAS-friendly resolution, routing,
authentication, and authorization for you, like this:

```
var http = require("http")
  , sajak = require("sajak")
  , server = http.createServer()

function User(){ ... }
User.prototype = {
  authenticate: function(auth, cb){ ... },
  save: function(cb){ ... },
  fetch: function(cb){ ... }
}

function TodoItem(){ ... }
TodoItem.prototype = {
  authorize: function(user, action, cb){ ... },
  save: function(cb){ ... },
  fetch: function(cb){ ... },
  destroy: function(cb){ ... }
}

server.on("request", sajak([User, TodoItem]).router)
server.listen(3000)
```

Sajak wires everything up so that you don't have to pepper your routes
with redundant/tedious/error-prone
authentication/authorization/resolution logic. It's useful as a
JSON-only API framework, or as a drop-in replacement for your
Express/Connect API router.

Check it out on Github:

https://github.com/jed/sajak

Any and all feedback appreciated:

http://news.ycombinator.com/item?id=3862841

Jed Schmidt
http://jed.is

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to