refactor server js; make calsses