Last week I started playing with NodeJS
1 2 3 4 5 6 7 8 9 10 11 12 13 14
So where would you use NodeJS. In real-time data processing. The perfect example of such usage is HummingBird, which uses NodeJS and MongoDB for producing real-time usage analytics and statistics for Gilt Groupe website, you can fork it on github.
To run a rebase command on Windows, you need to close all Cygwin processes, open
C:\cygwin\bin\ash.exe, and run:
After all the above dependencies were installed,
cd /path/to/your/nodejs, and run:
1 2 3
To run tests, execute:
Now that you have NodeJS installed, the first step is to create a “Hello World!” application, to do this, create example.js with the following content:
1 2 3 4 5 6 7 8 9
When the file is created, go to the directory its located and run:
If everything is correct, you should see something like this:
I used NodeJS and MongoDB to create a simple TinyURL application - you give it the url, it shortens it. The shortening algorithm is simple, each new url is assigned an auto-incrementing numeric index, which is then base 36 encoded to produce url key. Whenever url key is received, its base 36 decoded to get the numeric index, which is used to get the target location and send a 301 redirect header.
The application is very simple and lacks any kind of validation or error handling. The source code is open and available on github. Please feel free to fork it and use it. Feedback is much appreciated.