index.js 488 B

1234567891011121314
  1. 'use strict'
  2. import mongoose from 'mongoose'
  3. import { mongoDatabaseURI, dbLogger, TEST_MODE } from '../../config'
  4. import { formatLog, formatError } from '../functions'
  5. const connectDb = async () => {
  6. await mongoose.connect(mongoDatabaseURI, { useNewUrlParser: true, useFindAndModify: false })
  7. mongoose.connection.on('error', err => dbLogger.error(formatError(err)))
  8. if (!TEST_MODE) dbLogger.info(formatLog('The database connection was established.'))
  9. }
  10. export default connectDb