
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
pg-protocol
Advanced tools
The postgres client/server binary protocol, implemented in TypeScript
The pg-protocol npm package is a low-level library for parsing and serializing the PostgreSQL wire protocol. It is typically used as part of the PostgreSQL client libraries to handle communication with PostgreSQL servers.
Parsing PostgreSQL messages
This feature allows you to parse messages received from a PostgreSQL server. The `Parser` class emits a 'message' event whenever it successfully parses a message from the provided buffer.
const { Parser } = require('pg-protocol');
const parser = new Parser();
parser.on('message', msg => {
console.log('Received message:', msg);
});
const buffer = Buffer.from('some binary data from PostgreSQL server');
parser.parse(buffer);
Serializing PostgreSQL messages
This feature allows you to serialize messages to be sent to a PostgreSQL server. The `serialize` function takes a message type and the message content, and returns a buffer that can be sent over the wire.
const { serialize } = require('pg-protocol');
const buffer = serialize('query', 'SELECT * FROM users');
console.log('Serialized buffer:', buffer);
The `pg` package is a popular PostgreSQL client for Node.js. It provides a higher-level API for interacting with PostgreSQL databases, including connection pooling, query building, and transaction management. Unlike `pg-protocol`, which focuses on low-level protocol handling, `pg` abstracts away the details of the wire protocol and provides a more user-friendly interface.
The `pg-promise` package is another PostgreSQL client for Node.js that focuses on using promises for asynchronous operations. It provides a rich set of features for query building, transaction management, and connection pooling. Similar to `pg`, it abstracts away the low-level protocol details handled by `pg-protocol` and offers a more convenient API for developers.
The `node-postgres` package, also known as `pg`, is a comprehensive PostgreSQL client for Node.js. It includes support for connection pooling, query streaming, and prepared statements. Like `pg` and `pg-promise`, it provides a higher-level API compared to `pg-protocol`, making it easier to work with PostgreSQL databases without dealing with the wire protocol directly.
Low level postgres wire protocol parser and serializer written in Typescript. Used by node-postgres. Needs more documentation. :smile:
FAQs
The postgres client/server binary protocol, implemented in TypeScript
The npm package pg-protocol receives a total of 10,967,698 weekly downloads. As such, pg-protocol popularity was classified as popular.
We found that pg-protocol demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.