Registry / database / await-pg-cli

await-pg-cli

JSON →
library1.1.2jsnpmunverified

CLI utility that blocks until a PostgreSQL database is ready to accept connections. Version 1.1.2 is the latest stable release. It retries connecting with configurable interval and timeout. Minimal dependencies, ships TypeScript types. Use in CI/CD pipelines or scripts that depend on a database being available before proceeding.

npm install await-pg-cli
INSTALL
IMPORT
SIG · AWAIT-PG-CLI
A
await-pg-cli
databasejavascriptv1.1.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cli
import cli from 'await-pg-cli'
const cli = require('await-pg-cli')
ESM module; default export is the async CLI function.
waitForPG
import { waitForPG } from 'await-pg-cli'
import waitForPG from 'await-pg-cli'
Named export for programmatic use.
AwaitPGOptions
import type { AwaitPGOptions } from 'await-pg-cli'
import { AwaitPGOptions } from 'await-pg-cli'
TypeScript type only, not a runtime value.

Shows how to import and use the default export to wait for a PostgreSQL database.

import cli from 'await-pg-cli'; const dbUrl = process.env.DATABASE_URL ?? 'postgres://user:pass@localhost:5432/mydb'; await cli({ url: dbUrl, interval: 1000, timeout: 30000, }).catch((err: Error) => { console.error('Database not ready:', err.message); process.exit(1); });
Debug
Known issues
gotchaThe 'interval' and 'timeout' options are in milliseconds, not seconds.
fix
Specify values in milliseconds (e.g., 1000 for 1 second, 30000 for 30 seconds).
affects: >=1.0.0
gotchaIf the connection string is invalid or the database never becomes ready, the promise rejects after timeout.
fix
Wrap in try-catch and handle the error, e.g., log and exit.
affects: >=1.0.0
deprecatedDeprecated: Using CommonJS require() with this package may cause runtime errors.
fix
Use ESM import statement.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'await-pg-cli'
Package not installed.
fix
Run 'npm install await-pg-cli'.
TypeError: cli is not a function
Wrong import style, e.g., using require() instead of import.
fix
Use 'import cli from 'await-pg-cli''.
Upgrade
Version history
1.1.2latest on npm
Audit
Dependencies
pgrequiredUsed to connect to PostgreSQL
Agent activity
10 hits · last 30 days
node
8
OpenAI (training)
1
Resources
await-pg-cli — npm install await-pg-cli · libregistry