rewrite/port to nodejs

# work in progress