@growsari/idempotency
v1.0.5
Published
Idempotency project
Downloads
216
Keywords
Readme
Idempotency Package
Sometimes, we have functions that, when executed repeatedly, produce unwanted results. To get around that, use this. It saves a response for 10 mins and prevents any duplicate calls made while executing the function.
Usage
Easiest way to use this is through the function makeIdempotent
, wrapping your microservice controller function.
const { makeIdempotent } = require('@growsari/idempotency')
// ...
async function someController(params) {
// ...
}
// ...
module.exports = {
someController: makeIdempotent(testTimeout)
}
If you want to use your own logic in reading from the db, get the functions reserve
and save
, just take inspiration from how makeIdempotent
is implemented. lol