Documentation Index
Fetch the complete documentation index at: https://mintlify.com/miguelmartinezmestre/listen-postgres-changes-viewer/llms.txt
Use this file to discover all available pages before exploring further.
Database Configuration
The database configuration is defined indb.ts in the project root.
Connection Settings
db.ts
Configuration Options
The hostname or IP address of the PostgreSQL server.Example for remote server:
The port on which PostgreSQL is listening.Example for custom port:
The name of the database to connect to.
This database must have logical replication enabled and contain the required publication.
The PostgreSQL user for authentication.Required privileges:
SELECTon all monitored tablesREPLICATIONprivilege for logical replication
The password for the PostgreSQL user.
The PostgreSQL publication to subscribe to for change tracking.This must match the publication created in your database:
Server Configuration
The server configuration is located insrc/index.ts.
Port and Development Settings
src/index.ts
The port on which the HTTP/WebSocket server listens.To change the port:
Enables Hot Module Reloading for the React frontend.Automatically disabled in production (
NODE_ENV=production).When enabled, browser console logs are echoed to the server terminal.Useful for debugging frontend issues.
WebSocket Configuration
The WebSocket server is configured with handlers for connection lifecycle:src/index.ts
message handler
message handler
Handles incoming messages from WebSocket clients.Currently logs messages to the console. Extend this to handle client commands:
open handler
open handler
Called when a new WebSocket client connects.
- Adds the client to the active clients set
- Sends all accumulated changes to catch up the new client
- Logs the total number of connected clients
close handler
close handler
Called when a WebSocket client disconnects.
- Removes the client from the active clients set
- Logs the remaining number of connected clients
PostgreSQL Subscription
The subscription configuration determines what changes are captured:src/index.ts
Subscription Pattern
- All Tables
- Specific Table
- Schema Pattern
- Multiple Tables
Monitor all tables in all schemas:
Captured Operations
The subscription captures the following operations:- INSERT: New rows added to tables
- UPDATE: Existing rows modified
- DELETE: Rows removed from tables
TRUNCATE operations may not be captured depending on your PostgreSQL version and publication settings.
API Endpoints
The server exposes two endpoints:GET /api/changes
Returns all accumulated changes since server start.src/index.ts
WS /ws
WebSocket endpoint for real-time change notifications. Message types:Environment Variables
For production deployments, use environment variables instead of hardcoded values:db.ts
TypeScript Configuration
The project uses strict TypeScript settings intsconfig.json:
tsconfig.json
Next Steps
Setup
Return to the setup guide
Usage
Learn how to use the monitoring dashboard