@@ -8,17 +8,6 @@ import { Logger, Metrics, timer } from '@graphprotocol/common-ts'
88import { indexerError , IndexerErrorCode } from './errors'
99import { Sequelize } from 'sequelize'
1010
11- interface ConnectOptions {
12- host : string
13- port ?: number
14- username : string
15- password : string
16- database : string
17- logging ?: ( sql : string , timing ?: number ) => void
18- poolMin ?: number
19- poolMax ?: number
20- }
21-
2211export const parseBoolean = (
2312 val : string | boolean | number | undefined | null ,
2413) : boolean => {
@@ -74,35 +63,3 @@ export async function monitorEthBalance(
7463 }
7564 } )
7665}
77-
78- // Copied from @graphprotocol /common-ts, but adding pool size options
79- // TODO: Add these options in common-ts and remove this
80- export const connectDatabase = async ( options : ConnectOptions ) : Promise < Sequelize > => {
81- const { host, username, password, database, logging } = options
82-
83- // Use port 5432 by default
84- const port = options . port || 5432
85- const poolMin = options . poolMin || 0
86- const poolMax = options . poolMax || 10
87-
88- // Connect to the database
89- const sequelize = new Sequelize ( {
90- dialect : 'postgres' ,
91- host,
92- port,
93- username,
94- password,
95- database,
96- pool : {
97- max : poolMax ,
98- min : poolMin ,
99- } ,
100- logging,
101- } )
102-
103- // Test the connection
104- await sequelize . authenticate ( )
105-
106- // All good, return the connection
107- return sequelize
108- }
0 commit comments