News for hackers. Stuff that matters.
Re:Why node.js disappoints me by pilif on Monday September 27, 2010 @11:23AM (#1731967)
agreed. My first bigger node project (http://tempalias.com) works without generating even a single byte of HTML dynamically on the server.

It's all plain HTML and JavaScript statically served and talking to the server via a REST API.

This way I don't have to "bolt on" an API that might be incomplete. Instead, the frontend uses exactly the same API as any prospective client would.

When I started the thing, I was using the Express framework, but soon began to feel exactly like the original poster. Express was porting Rails to Node and I wanted something else.

Hence I moved to paperboy to serve the static files and did the (simple!) API on my own - plugging paperboy into an existing node server with existing endpoints is incredibly easy (or I could serve the static files directly, but I wanted the code to work without external dependencies to help the community to get a service of their own to run).

If you are interested in the development (tempalias is MIT licensed and available at github), I would recommend you either the development journal (http://www.gnegg.ch/tag/tempalias) or the talk I gave at jsconf.eu (http://bit.ly/b4gsrL)

Re:Why node.js disappoints me by kls on Monday September 27, 2010 @12:36PM (#1732247)
Thanks for the reply, my next project is going to be doing the REST services with Node. I have been using Java for my services because until Node I really did not see a big enough reason to move platforms. What are you using for your REST services implementation, a Node library or did you roll your own? I did not know about Paperboy so thanks for pointing me to that project.
Re:Why node.js disappoints me by pilif on Monday September 27, 2010 @01:33PM (#1732460)
in this case, the API was so simple, I could easily roll my own (it's not even a real framework - I have one resource, the alias and I allow basically just POST to /aliases to create one at the moment).

The beauty about node is that it's so simple to extend and add the functionality you need. No magic, no huge framework to learn.

The little things you get though work awesomely well and are a pleasure to use.

Re:Why node.js disappoints me by kls on Monday September 27, 2010 @01:48PM (#1732538)
If you could find the time to shot me an email (possible with some samples, or some links) of how you did your REST services with Node, I would be forever in your debt. My email is in my profile if you get a chance.
Re:Why node.js disappoints me by pilif on Monday September 27, 2010 @05:17PM (#1733465)
if it wasn't a bit ugly (organically grown, just one endpoint), I'd direct you to the source code of the tempalias HTTP server.

You can still have a look at it. As I said though, it's really ugly and I should really split it up into multiple files, factor out the common stuff and make the whole thing more clear.

Still. Here goes:

http://github.com/pilif/tempalias/blob/master/lib/tempalias_...

Lines 30 and following handle calls to /aliases (in my case, that's just a POST to /aliases to create an alias - later I'd add PUT to /aliases/<id> to update it and DELETE /aliases/<id> to delete it - assuming that a correct update key (part of the response to creation) has been created.

As I said: Butt-ugly code. Don't do it like this - factor out common stuff, create smaller functions for the various parts of the needed setup.

Re:Why node.js disappoints me by kls on Tuesday September 28, 2010 @08:26AM (#1735429)
Thanks don't worry about the ugly. We all have pieces we are not proud off. I would just like to see the basic of what you did so I have a head start when I jump into Node.

I can give you this, it is prettier than any code I have written in Node (if it is not apparent from my posts, I have not worked in Node).

Re:Why node.js disappoints me by percept on Monday September 27, 2010 @03:10PM (#1732936)
Post it here! Or someplace we can access, if it's useful.