Update server.js

Refactor REST api