There are a number of places in water-abstraction-system where we need to generate a UUID. This is what the records in the DB use for their primary keys. We generate them in tests, for performance reasons (reduce hits on the DB) or simply because the previous team forgot to set the table to automatically generate them!
You have to require() the module and then it's a one-liner to generate the method. So, moving it to our own thing didn't seem necessary.
But there is some config you need to apply, and we have duplicated that in a number of places. Who knows where a new dev will encounter randomUUID({ disableEntropyCache: true }) for the first time! 😆
Admittedly, it's borderline whether there is value in doing this. But we've come to the conclusion we should.
There are a number of places in water-abstraction-system where we need to generate a UUID. This is what the records in the DB use for their primary keys. We generate them in tests, for performance reasons (reduce hits on the DB) or simply because the previous team forgot to set the table to automatically generate them!
You have to
require()
the module and then it's a one-liner to generate the method. So, moving it to our own thing didn't seem necessary.But there is some config you need to apply, and we have duplicated that in a number of places. Who knows where a new dev will encounter
randomUUID({ disableEntropyCache: true })
for the first time! 😆Admittedly, it's borderline whether there is value in doing this. But we've come to the conclusion we should.