How To Create a RESTful API with Node.js
In a previous how-to, we created a RESTful API to search videos, performing the actual search through YouTube Data API. To provide additional support for languages and to demonstrate that we are stating general principles that can be implemented using (almost) any programming language/technology, in this report we will explain how to implement the same interface using node.js. As you’ll see, using a couple of Node modules, the job is even easier than with Google App Engine.
Here is a list of features we will implement:
We’ll need to route three different paths, as we did with our Python implementation for Google App Engine. However, while the Python implementation required that we get into the details of regular expressions to define the rules to match those paths, with the Express module for Node we will be able to effortlessly catch the parameters in the URLs.
Setting Up Node.js
Now you can create a folder to contain your project. For example, I created one named “pweb.”
Enter your folder name, and create a new file named package.json. This configuration file will be needed if you export your module.
Read more/Post's link: