Rewrite node.js Code