William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

NodeJS: the good parts?

NodeJS: the good parts? A Skeptic’s View

Here is a interesting video in youtube: NodeJS: the good parts? A Skeptic’s View, which I extract and did a simple summary.
The node-promise is very interesting which I probably use in future.

------@@ Node.js ------
Long running computations => blocks event loop for other requests
Need to run outside of main event loop
community: web workers threads
Built-in: NodeJS child processes

Micro-service rchitecture

1. Modules
foo.js: exports.sayHello = function() {}
var foo = require("foo");

2. Node as static files service:
fs.exists(filePath, function(exists) {
  if(exists) {
    res.writeHead(200, {"content-type": mime.lookup(path.basename(filePath)) });
 app.configure(function() {
   app.use(express.static(__dirname + '/public'));

3. RESTful WS with express/restify:(Easy URL routing and destructuring)
app.get('/portfolio/:userId', function(req, res) {
  var portfolio = retrievePortfolio(req.params.userId);

-- Use 'request' module to pass: Proxying to backend Servers

4. Deliverying events to the browser
websocket, socket.io

5. Promises (simply codes)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: