porting php to node.js