I’m intrigued by node – partly because of all the recent hype and ‘cool kid’ factor – but mostly because I like the idea of having a single language context on both client and server. Plus, the overall programming style for authoring Web apis feels similar to the style I enjoyed in sinatra. At any rate, in an effort to better understand node, I’m porting RestBugs from ASP.NET Web API to node.
Here’s where I’m at currently – https://github.com/howarddierking/RestBugs/blob/NodeJS/RestBugs-Node/app.js
It feels like I’m actually close to a completely working application – however, there are a couple things (1 thing really) that’s keeping it from working, and before I go write a bunch of code to do something totally hacky, I would rather just ask you good people. Here’s a sample of the type of code in question.
Now, you probably already know that the route handler code above won’t work. Why? Because MongoDB is giving me back a JSON object and I need to work with it as a Bug object. If I was using JSON instead of form URL encoding for my POST input, I would likely run into the same problem on that side of the fence as well. This leads me to my question:
What is the right way to think about moving between JSON input/output objects and “domain” objects?