Node.js example of bidirectional JSON transport
Switch branches/tags
Nothing to show
Latest commit a59ba21 Mar 9, 2011 @olooney first commit
Permalink
Failed to load latest commit information.
README first commit Mar 9, 2011
client.html first commit Mar 9, 2011
json-cache.js first commit Mar 9, 2011

README

JSON Cache Example with node.js
Copyright (c) 2011 Oran Looney

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.
-----------------------------------------------------------------------------

This is an example, not a useful library.  It demostrates bi-directional
JSON transport to a simple service capable of caching arbitrary JSON objects
by id.  To run the example, type:

	$ node json-cache.js

That will start the server running.  It will tell you a URL of a test page that 
uses jQuery to consume the service.  You can then use the put() and get()
calls to cache JSON objects.  Objects persist only in memory in the server
process, and are lost when the server stops.

From my point of view, the interesting part is the transport: serializing, 
deserializing, GETing, and POSTing with correct MIME types and basic error
handling, both server-to-client and client-to-server.