Update app.js

connection to the database and errors checking