Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@node-idempotency/fastify

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@node-idempotency/fastify

fastify plugin that provides Race-Condition free idempotency for HTTP requests, preventing unintended duplicate operations.

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source
@node-idempotency/fastify

A Fastify plugin that makes requests idempotent Implements @node-idempotency/core as fastify plugin.


Why?

Network requests are unpredictable; clients/proxies may send duplicate or concurrent requests due to retries or network issues. To ensure smooth operation, servers must process each request only once. This package detects and handles duplicates, preventing issues like double charging the customer. It's:

  • Race Condition free: Ensures consistent behavior even during concurrent requests.
  • Modular: Easily integrates with your storage or existing implementation.(as simple as registering a plugin to fastify)
  • Customizable: options to tweak the library as per your need.
  • RFC compliant: Adheres to standards for compatibility with other systems/clients.

How?

No Image

instal
npm i @node-idempotency/fastify
usage
import fastify from "fastify";
import fp from "fastify-plugin";
import {
  idempotencyAsPlugin,
  type IdempotencyPluginOptions,
  StorageAdapterEnum,
} from "@node-idempotency/fastify";

const server = fastify();
server.register(fp<IdempotencyPluginOptions>(idempotencyAsPlugin), {
  storage:{
    adapter: StorageAdapterEnum.memory
    options: ...adapterOptions
  },
  //...IdempotencyOptions
});

//...your rest of logic
export default server;
  • storage.adapter can either be memory, redis or an instance of Storage interface.
  • storage.options are options to the storage client, required for redis, is client options of redis client.
  • idempotencyOptions are the IdempotencyOptions passed to @node-idempotency/core/Idempotency

Keywords

FAQs

Package last updated on 12 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc