@growsari/idempotency

1.0.5 • Public • Published

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

/@growsari/idempotency/

    Package Sidebar

    Install

    npm i @growsari/idempotency

    Weekly Downloads

    44

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    5.06 kB

    Total Files

    4

    Last publish

    Collaborators

    • gs.dwight.badua
    • leland.growsari
    • melyo
    • prasad.riktam
    • ddimaano.gs
    • madhugogineni