All files / database/config sequelize-pool.js

100% Statements 13/13
100% Branches 0/0
100% Functions 2/2
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301x 1x   1x 1x   5x   1x                     1x 1x 1x   4x   1x        
const Sequelize = require('sequelize');
const uuid = require('uuid/v4');
 
const {getConfig} = require('../config/config');
const config = getConfig();
 
Sequelize.formatLogging = (sql) => sql.replace(/[\r\n\t]+/g, ' ').replace(/\s+/g, ' ');
 
const instance = new Sequelize(config.url, {
  dialect: 'postgres',
  pool: {
    min: 0,
    max: 10,
  },
  dialectOptions: {
    ssl: true,
  },
});
 
instance.id = uuid();
instance.types = Sequelize;
instance.formatLogging = Sequelize.formatLogging;
 
const getInstance = () => instance;
 
module.exports = {
  Sequelize,
  getInstance,
};