(nodeConfig: NodeConfig, option: DbOption)
| 59 | }; |
| 60 | |
| 61 | const buildSequelizeOptions = (nodeConfig: NodeConfig, option: DbOption): SequelizeOption => { |
| 62 | const logger = getLogger('SQL'); |
| 63 | |
| 64 | return { |
| 65 | ...option, |
| 66 | dialect: 'postgres', |
| 67 | ssl: nodeConfig.isPostgresSecureConnection, |
| 68 | dialectOptions: { |
| 69 | ssl: { |
| 70 | rejectUnauthorized: false, |
| 71 | ca: nodeConfig.postgresCACert, |
| 72 | key: nodeConfig.postgresClientKey, |
| 73 | cert: nodeConfig.postgresClientCert, |
| 74 | }, |
| 75 | }, |
| 76 | pool: { |
| 77 | max: nodeConfig.pgPoolMax, |
| 78 | min: nodeConfig.pgPoolMin, |
| 79 | acquire: nodeConfig.pgPoolAqcuire, |
| 80 | idle: nodeConfig.pgPoolIdle, |
| 81 | evict: nodeConfig.pgPoolEvict, |
| 82 | }, |
| 83 | logging: (sql: string, timing?: number) => { |
| 84 | logger.debug(sql); |
| 85 | }, |
| 86 | }; |
| 87 | }; |
| 88 | |
| 89 | export async function establishNewSequelize(nodeConfig: NodeConfig): Promise<Sequelize> { |
| 90 | return sequelizeFactory(buildSequelizeOptions(nodeConfig, DEFAULT_DB_OPTION))(); |
no test coverage detected