refact server.js