Skip to content

Node Toy

teknopaul edited this page · 2 revisions
Clone this wiki locally


Node Toy is like an instant server-side. Its a REST interface that accepts and returns JSON to any ol’ URL (that starts with /data/), And it also hosts your HTML etc at /app/

Quite often when developing front end code that calls a JSON interface I create flat files with extension .json and have a local Apache instance serve the files on given URLs with the correct mime/type. This means you can concentrate on the front end code HTML and JS while the backend is being worked on by someone else, or by you at a later date.

Node Toy is built with this in mind but talking JSON in both directions, you can POST any old blob of JSON to a URL and the node server will save it and make it available for a subsequent GET. If you GET to a directory, not a file, you get a listing back of all the *.json files.

I have done the same job in the past with a tomcat server but thats a big chunk of RAM you might not be happy to give up. A node server takes up about as much RAM as a tab in chrome.

Node Toy comes with a tester page in the /app/test.html so you can try out GETing and POSTing without writing and JavaScript yet. There is also a jQuery version and some css and image, delete them if they get int he way an d you don't use the tester.

Its not a bad idea to follow REST principals for larger applications. To test the concept I knocked up a todo list in just front end code HTML/JS/CSS. The resulting code was hacked out fast, but its not that bad and it proves that not all APPs need a hefty backend, but almost all of them need some kind of persistence. Persistence is the one thing that a browser does not give you. I guess modern browsers do give you persistence but I like to be able to see and back up my data and not have to worry about it dissappearing when you flush the caches or upgrade the version. Node toy stores the files as flat files in the file system.

I can see this tool being handy to knock up little desktop APPs where anybody with a bit of JavaScript experience can chip in to build up the features, and also quite neat for adding bits of interaction to website prototypes.

Something went wrong with that request. Please try again.