Refactored onRequest method
Made server.js a module