changed gateway.js to app.js, added a production mode with catch all for unhandeled errors