converted main server to js from coffee