Skip to content
Browse files

add README detail

  • Loading branch information...
1 parent f2ab969 commit a89c32b0b846aa5c367a0440e3b351f503eba9cd @jed committed Apr 19, 2012
Showing with 10 additions and 10 deletions.
  1. +10 −10 README.md
View
20 README.md
@@ -39,16 +39,16 @@ server.listen(3000)
How it works
------------
-Sajak returns a simple http listener. Upon every request, it:
-
-- parses incoming query, body, and auth data into JavaScript objects,
-- instantiates a new model based on the request pathname and query,
-- resolves any model URLs in the request into actual model instances,
-- calls the user's `authenticate` method to authenticate the user,
-- calls the resource's `authorize` method to authorize the user action,
-- extends the resource with any incoming body data,
-- calls `fetch`/`save`/`destroy` on the resource as per the request method, and
-- serializes and returns the results to the client.
+Sajak returns a simple http listener. Upon every request, it runs through the following lifecycle:
+
+1. parse the incoming query, body, and auth data into JavaScript objects.
+2. instantiate a new model based on the request pathname and query. so `/users/sajak` would call the `User` constructor with `{id: "sajak"}`.
+3. instantiate any model URLs in the request. so if you `POST` something like `{"user.href": "/users/sajak", "text": "Hello."}` to `/notes`, the user is reified into an actual `User` instance before being passed to the `Note` constructor.
+4. call the `User`'s `authenticate` method to authenticate the user.
+5. call the resource's `authorize` method to authorize the user action.
+6. extend the resource with any incoming body data.
+7. call the appropriate Backbone.js-style `fetch`/`save`/`destroy` method on the resource, as per the request method.
+8. serialize and return the results to the client.
Since a Sajak app is just a listener, it can be used standalone, or as middleware in any Express/Connect app. With Express, any requests that don't match or return an error are passed to `next`, as with any other middleware.

0 comments on commit a89c32b

Please sign in to comment.
Something went wrong with that request. Please try again.