Registry / database / voicer-pg-lib

voicer-pg-lib

JSON →
library2.1.3jsnpmunverified

Custom library developed by Voicer for interacting with PostgreSQL databases. Current stable version is 2.1.3. Provides a simplified wrapper around the `pg` (node-postgres) driver for common database operations like querying and connection management using environment variables. Designed for internal use within Voicer projects; not actively maintained for public adoption. Release cadence is low, with updates tied to internal needs. Key differentiator: opinionated setup via .env variables, reducing boilerplate for Voicer's infrastructure. Note: the library is not published on npm (only available via GitHub), and usage is strictly for PostgreSQL without ORM features.

npm install voicer-pg-lib
INSTALL
IMPORT
SIG · VOICER-PG-LIB
V
voicer-pg-lib
databasejavascriptv2.1.3
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.

query
import { query } from 'voicer-pg-lib'
const query = require('voicer-pg-lib').query
Supports ESM and CJS; named export.
pool
import { pool } from 'voicer-pg-lib'
import pool from 'voicer-pg-lib'/pool
Instance of pg.Pool configured via environment variables; use carefully with concurrent operations.
checkConnection
import { checkConnection } from 'voicer-pg-lib'
const { checkConnection } = require('voicer-pg-lib'
Returns promise resolving to true/false; ESM only in v2.

Shows basic query execution and connection pooling using voicer-pg-lib with environment variables for configuration.

import { query, pool } from 'voicer-pg-lib'; async function main() { try { const res = await query('SELECT NOW()', []); console.log('Current time:', res.rows[0].now); const client = await pool.connect(); const result = await client.query('SELECT $1::text as name', ['Voicer']); console.log('Name:', result.rows[0].name); client.release(); } catch (err) { console.error('Database error:', err); } } main();
Debug
Known issues
breakingLibrary renamed or restructured in v2.0.0: exports changed from default to named exports.
fix
Update imports to use named exports: `import { query } from 'voicer-pg-lib'` instead of `import pgLib from 'voicer-pg-lib'`.
affects: >=2.0.0
gotchaEnvironment variables PG_USER, PG_PASSWORD, PG_DATABASE, PG_HOST, PG_PORT are required and must be set before importing the library.
fix
Ensure .env file is loaded before importing (e.g., with dotenv) or set environment variables in runtime.
affects: >=1.0.0
deprecatedThe `pool` export is a singleton; creating multiple pools may lead to connection limit issues.
fix
Use `query` function for single queries; for complex transactions, acquire a client from `pool` and release it promptly.
affects: >=2.0.0
gotchaLibrary does not support TypeScript types; all types are `any`.
fix
Install @types/pg for type hints, but custom types may be needed for query results.
affects: >=2.0.0
Errors
Common errors & fixes
Error: connect ETIMEDOUT
Database host unreachable or wrong port/host in .env
fix
Check PG_HOST and PG_PORT values; ensure database server accepts connections from your IP.
Error: password authentication failed for user ...
Wrong PG_USER or PG_PASSWORD in .env
fix
Verify .env file has correct credentials; ensure user exists and has correct permissions.
TypeError: Cannot destructure property 'query' of ...
Using CommonJS require incorrectly or import from wrong path
fix
Use `import { query } from 'voicer-pg-lib'` (ESM) or `const { query } = require('voicer-pg-lib')` (CJS).
Error: database ... does not exist
PG_DATABASE environment variable set to a database that doesn't exist
fix
Create the database or update .env with an existing database name.
Upgrade
Version history
2.1.3latest on npm
Audit
Dependencies
pgrequiredDirect dependency for PostgreSQL client connections and queries
dotenvoptionalUsed to load database configuration from .env file
Agent activity
22 hits · last 30 days
node
16
Meta
1
Amazon
1
OpenAI (training)
1
Resources
voicer-pg-lib — npm install voicer-pg-lib · libregistry