Registry / database / pg-gateway

pg-gateway

JSON →
library0.3.0-beta.4jsnpmunverified

pg-gateway is a TypeScript library that implements the PostgreSQL wire protocol for the server side, enabling developers to build custom Postgres-compatible proxies, middleware, or gateways. The current version is 0.3.0-beta.4, indicating an early beta stage with potential breaking changes. It focuses on low-level protocol handling, differentiating from higher-level clients like node-postgres by giving direct control over the protocol flow. Releases are infrequent and experimental.

npm install pg-gateway
INSTALL
IMPORT
SIG · PG-GATEWAY
P
pg-gateway
databasejavascriptv0.3.0-beta.4
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

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

default
import PgGateway from 'pg-gateway'
const PgGateway = require('pg-gateway')
The package is ESM-first but may have a CommonJS fallback. Check package.json exports.
PgGateway
import { PgGateway } from 'pg-gateway'
import PgGateway from 'pg-gateway'
Named export for the library class.
BackendMessage
import { BackendMessage } from 'pg-gateway'
import BackendMessage from 'pg-gateway'
Named export for backend message types, useful for parsing protocol messages.

Creates a simple TCP server that uses pg-gateway to proxy client connections to a real PostgreSQL instance, demonstrating the primary use case.

import PgGateway from 'pg-gateway'; import net from 'node:net'; const gateway = new PgGateway(); // Create a server that proxies to a real PostgreSQL backend net.createServer((socket) => { gateway.handleClient(socket, { backend: { host: 'localhost', port: 5432, user: 'user', password: process.env.PGPASSWORD ?? '' } }); }).listen(5433, () => { console.log('Gateway listening on 5433'); });
Debug
Known issues
breakingBeta version 0.3.0 may have breaking changes from earlier alphas. No stable release yet.
fix
Pin to a specific version and test upgrades carefully. Consult changelog if available.
affects: <0.3.0
gotchaThe package is intended for server-side usage only; it does not work in browser environments due to reliance on Node.js net module.
fix
Do not import in client-side code; ensure bundler excludes it for browser bundles.
affects: >=0.0.0
deprecatedNo known deprecated APIs yet, but as a beta package, certain APIs may be removed later.
fix
Watch for updates and migration guides.
affects: >=0.3.0-beta.0
Errors
Common errors & fixes
TypeError: PgGateway is not a constructor
Importing the default export incorrectly when using CommonJS or mismatched module system.
fix
Use `import PgGateway from 'pg-gateway'` in ESM, or `const PgGateway = require('pg-gateway').default` in CommonJS.
Cannot find module 'pg-gateway'
Package not installed or incorrect import path.
fix
Install with `npm install pg-gateway` and verify the import path is correct.
Error: The module 'pg-gateway' is not compatible with the 'node' platform
Attempting to use in a browser or non-Node environment.
fix
Use only in Node.js; exclude from browser bundles.
Upgrade
Version history
0.3.0-beta.4latest on npm
Audit
Dependencies
node:bufferrequiredBuffer is used for handling binary protocol data
Agent activity
7 hits · last 30 days
node
6
Amazon
1
Resources
pg-gateway — npm install pg-gateway · libregistry