1.0.7 • Published 1 year ago

ts-pg-interceptor v1.0.7

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

TCP Proxy with PostgreSQL Request Interceptor

alt text

A TCP proxy server with the ability to intercept and manipulate PostgreSQL requests. This package provides an event-driven approach to data handling, making it easy to listen for and modify incoming requests.

Create an interceptor instance


// Create a new PostgresQueryInterceptor instance with the desired options
const interceptor = new PostgresQueryInterceptor({
  // Interceptor server options
  listenPort: 6432,
  // Target Postgres connection options
  targetHost: 'localhost',
  targetPort: 5432
});

// Start the interceptor and begin intercepting incoming requests
interceptor.start()

Modify incoming requests


interceptor.onQuery = (query: Buffer, socket: net.Socket) => {
    const modifiedQuery = query
    // Your logic to modify the query as desired
    // Use the socket as needed to manage the connection
    // The returned query will be sent to the target Postgres server
    return modifiedQuery
}

Modify outgoing results


interceptor.onResult = (result: Buffer, socket: net.Socket) => {
    const modifiedResult = result
    // Your logic to modify the result as desired
    // Use the socket as needed to manage the connection
    // The returned result will be sent to the client
    return modifiedResult
}

Stop the interceptor


interceptor.stop()
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago