(database: Knex)
| 77 | } |
| 78 | |
| 79 | async function waitForDatabase(database: Knex) { |
| 80 | const tries = 5; |
| 81 | const secondsBetweenTries = 5; |
| 82 | |
| 83 | for (let i = 0; i < tries; i++) { |
| 84 | if (await hasDatabaseConnection(database)) { |
| 85 | return true; |
| 86 | } |
| 87 | |
| 88 | await new Promise((resolve) => setTimeout(resolve, secondsBetweenTries * 1000)); |
| 89 | } |
| 90 | |
| 91 | // This will throw and exit the process if the database is not available |
| 92 | await validateDatabaseConnection(database); |
| 93 | |
| 94 | return database; |
| 95 | } |
no test coverage detected