pgwire-lite
is a minimalistic PostgreSQL wire protocol library for Node.js. It is designed to be a lightweight alternative to other PostgreSQL wire protocol libraries, providing a simple and efficient way to connect to and interact with PostgreSQL wire protocol-compatible servers, such as stackql
.
- Lightweight and minimal PostgreSQL wire protocol client
- Supports both secure (TLS) and non-secure connections
- Easily customizable and extendable
- Designed to interact with PostgreSQL wire protocol-compatible services like
stackql
To install pgwire-lite
, run the following command:
npm i @stackql/pgwire-lite
Below is an example of how to use pgwire-lite
to connect to a PostgreSQL-compatible server with both TLS and non-TLS options.
import { runQuery } from '@stackql/pgwire-lite';
const connectionOptions = {
user: 'stackql',
database: 'stackql',
host: 'localhost',
port: 5444,
debug: false,
};
(async () => {
try {
const result = await runQuery(connectionOptions, "REGISTRY LIST");
console.info(result.data);
} catch (error) {
console.error('Error executing queries:', error.message);
}
})();
import fs from 'fs';
import { runQuery } from '@stackql/pgwire-lite';
const connectionOptions = {
user: 'stackql',
database: 'stackql',
host: 'localhost',
port: 5444,
debug: true,
cert: fs.readFileSync('/path/to/client_cert.pem'),
key: fs.readFileSync('/path/to/client_key.pem'),
ca: fs.readFileSync('/path/to/server_cert.pem'),
};
(async () => {
try {
const result = await runQuery(connectionOptions, "REGISTRY LIST");
console.info(result.data);
} catch (error) {
console.error('Error executing queries:', error.message);
}
})();
You can test pgwire-lite
using stackql by following these steps.
curl -L https://bit.ly/stackql-zip -O && unzip stackql-zip
-
Test without TLS:
npm test
-
Test with TLS:
npm run secure-test # or NODE_DEBUG=tls,node::http npm run secure-test
-
Test without TLS:
sh start-server.sh node example/app.js sh stop-server.sh
-
Test with TLS:
sh start-secure-server.sh node example/app.js true sh stop-server.sh
to publish or update on npmjs:
npm login
npm publish --access public