constmongoose=require('mongoose');constutil=require('util');constdebug=require('debug')('express-mongoose-es6-rest-api:index');constconfig=require('./config');// connect to mongo dbconstmongoUri=config.mongo.host;mongoose.connect(mongoUri,{keepAlive:1});mongoose.connection.on('error',()=>{thrownewError(`unable to connect to database: ${mongoUri}`);});// print mongoose logs in dev envif(config.MONGOOSE_DEBUG){mongoose.set('debug',(collectionName,method,query,doc)=>{debug(`${collectionName}.${method}`,util.inspect(query,false,20),doc);});}