https://github.com/jcoreio/wait-for-postgres
Wait for a Postgres database to become available
https://github.com/jcoreio/wait-for-postgres
Last synced: about 1 year ago
JSON representation
Wait for a Postgres database to become available
- Host: GitHub
- URL: https://github.com/jcoreio/wait-for-postgres
- Owner: jcoreio
- License: apache-2.0
- Created: 2018-11-29T03:54:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T21:52:00.000Z (over 3 years ago)
- Last Synced: 2025-03-03T04:17:28.190Z (over 1 year ago)
- Language: TypeScript
- Size: 2.42 MB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wait For Postgres
Wait for a Postgres database to become available
## Installation
`npm install --save @jcoreio/wait-for-postgres`
or
`yarn add @jcoreio/wait-for-postgres`
## Usage
Wait for Postgres to be ready, throwing an `Error` after a timeout:
```ts
import { waitForPostgres } from '@jcoreio/wait-for-postgres'
// returns when Postgres becomes available, or throws an Error if Postgres does not become available
// before the timeout expires
await waitForPostgres({
host: 'localhost',
user: 'postgres',
password: 'password',
database: 'database',
timeout: 30 * 1000 // milliseconds
})
```
Check if Postgres is ready, returning `true` when ready or `false` if the timeout expires before the
database is ready:
```ts
import { isPostgresReady } from '@jcoreio/wait-for-postgres'
// returns true when Postgres becomes available, or returns false if Postgres does not become available
// before the timeout expires
const isReady = await isPostgresReady({
host: 'localhost',
user: 'postgres',
password: 'password',
database: 'database',
timeout: 1000 // milliseconds
})
```
## License
[Apache-2.0](LICENSE)