I've been using PostgreSQL with Node.js, and I've developed some useful patterns for breaking down SQL queries into smaller parts, because small building blocks are easier to reason about and test. An important consideration when doing this is keeping query text and parameters separate.
ComposableQuery helped me write safer and more readable code, so I decided to package it as a library and release it on GitHub as open source.
ComposableQuery is here: https://github.com/anderjason/composablequery