socketio / socket.io-postgres-adapter

The Socket.IO Postgres adapter, allowing to broadcast events between several Socket.IO servers
https://socket.io
MIT License
24 stars 8 forks source link

Add pg dependency #6

Closed sjoerdsmink closed 2 years ago

sjoerdsmink commented 2 years ago

The package pg is a dependency which is needed. To put this in the devDependencies, but mentioning in the readme that it's required seems contradicting. Also updated the TypeScript reference to pg-pool instead of an any.

darrachequesne commented 2 years ago

That's a fair point. One potential use case is to allow the user to provide another PostgreSQL client: in the case of the Redis adapter for example, you can provide a client from redis or ioredis.

Also, it would mean that we force the user to use pg@^8.0.0, which may not be great. What do you think?

sjoerdsmink commented 2 years ago

Still if you want to support other pool clients, you need to define the types. Because otherwise this.pool.connect() and this.pool.query would crash. The whole code expects pg-node's pool in this argument, e.g. pool.connect() should return a client, which can have client.query(), client.removeAllListeners(), client.release(), client.on(). Don't think there's any other package that does exactly that :)

pg@^8.0.0 means pg version 8.x.x. In case a user wants another major version, npm or yarn will install the pg dependency in node_modules/@socket.io/postgres-adapter/node_modules/pg

darrachequesne commented 2 years ago

Well that makes sense! Merged as https://github.com/socketio/socket.io-postgres-adapter/commit/d6d74d51051f46b6f24ba47b4e1e0cd65b2ca2c0, thanks :+1: