Shout out to https://www.npmjs.com/package/sql-template-strings, which does a similar template string SQL escaping standalone.
This reminds me of a friend of mine.. He got struggled with a programming-related task. When he gave up, he turned to StackOverflow, where he found the exact answer there, ready to be copy/paste. Ironically, it turns out that he was the one who answered it a few years back :)