Refactor code as a nodejs module