@jcoreio/wait-for-postgres
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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:

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:

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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    7
  • 1.0.0
    0

Package Sidebar

Install

npm i @jcoreio/wait-for-postgres

Weekly Downloads

7

Version

2.0.0

License

Apache-2.0

Unpacked Size

20.7 kB

Total Files

6

Last publish

Collaborators

  • gravitate1838
  • manojrsingireddy
  • avramdodson
  • forrest-keller
  • jrmclaurin
  • jedwards1211
  • eladendorf