hapi-node-postgres
hapi-node-postgres copied to clipboard
Could there be a way to whitelist which routes get connected?
Hi @jedireza!
I ran into an interesting problem, because of the way my API is structured and me not fully understanding the hapi route lifecycle.
Basically, I had some text/event-stream routes which needed to stay alive for as long as possible. So when something would hit those routes, they would call Pg.connect but then never return the client to the pool.
There might be a different detach server event that would fix this, but I wanted to keep it as tail for all my other routes which did hit the DB.
For my own use case, I forked this to only run this plugin for specific routes (I did it based on the tags. Not super happy with it, but it worked.)
Anyway, this isn't an issue with this plugin really, but I thought it was good enough to open an issue because I was having a tough time trying to figure out why all my requests would hang after loading 5 or so instances of my site (my DB is capped at 20 simultaneous connections).
I'd be happy to write up a PR with either a config option for this, or a note in the README specifying this behavior.
👋 @lukekarrys
That is an interesting problem indeed. I'm interested in what a PR would look like. 👍