open-index/open-npm huggingface dataset:
npm package: @idempot/core
Description: Core idempotency logic for idempot middleware
Latest version: 1.2.0

# @idempot/core

Core idempotency logic for framework adapters and storage backends.

## Usage

Install alongside a framework adapter:

```bash
npm install @idempot/hono-middleware @idempot/sqlite-store
```

```javascript
import { idempotency } from "@idempot/hono-middleware";
```

## For Package Maintainers

Framework adapters and storage backends depend on this package for:

- Request fingerprinting (`generateFingerprint`)
- Validation logic (`validateIdempotencyKey`, `checkLookupConflicts`)
- Resilience patterns (`withResilience`)
- Default configuration (`defaultOptions`)
- Store interface definition (`IdempotencyStore`)

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { idempotency } from "@idempot/core";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/express-middleware
Description: Express middleware for idempotency
Latest version: 1.2.0

# @idempot/express-middleware

Express middleware for idempotency.

## Installation

```bash
npm install @idempot/express-middleware
```

### Available Stores

Choose a storage backend that fits your infrastructure:

- `@idempot/sqlite-store` - great for development and single-node deployments
- `@idempot/redis-store`
- `@idempot/postgres-store`
- `@idempot/mysql-store`
- `@idempot/bun-sql-store` - Bun runtime

## Usage

```javascript
import express from "express";
import { idempotency } from "@idempot/express-middleware";
import { SqliteIdempotencyStore } from "@idempot/sqlite-store";

const app = express();
const store = new SqliteIdempotencyStore({ path: ":memory:" });

app.use(express.json());

app.post("/orders", idempotency({ store }), async (req, res) => {
  const orderId = crypto.randomUUID();
  res.status(201).json({ id: orderId, ...req.body });
});

app.listen(3000);
```

## API

### `idempotency(options)`

Creates Express middleware for idempotency.

**Options:**

- `store` (required): Storage backend implementing `IdempotencyStore`
- `headerName`: Header name for idempotency key (default: `"Idempotency-Key"`)
- `required`: Whether idempotency key is required (default: `false`)
- `ttlMs`: Time-to-live for idempotency records in milliseconds
- `excludeFields`: Fields to exclude from fingerprint calculation
- `resilience`: Circuit breaker and retry options

**Returns:** Express middleware function with `circuit` property for monitoring.

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { idempotency } from "@idempot/express-middleware";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/fastify-middleware
Description: Fastify middleware for idempotency
Latest version: 1.2.0

# @idempot/fastify-middleware

Fastify middleware for idempotency.

## Installation

```bash
npm install @idempot/fastify-middleware
```

### Available Stores

Choose a storage backend that fits your infrastructure:

- `@idempot/sqlite-store` - great for development and single-node deployments
- `@idempot/redis-store`
- `@idempot/postgres-store`
- `@idempot/mysql-store`
- `@idempot/bun-sql-store` - Bun runtime

## Usage

```javascript
import Fastify from "fastify";
import { idempotency } from "@idempot/fastify-middleware";
import { SqliteIdempotencyStore } from "@idempot/sqlite-store";

const fastify = Fastify();
const store = new SqliteIdempotencyStore({ path: ":memory:" });

fastify.post(
  "/orders",
  { preHandler: idempotency({ store }) },
  async (request, reply) => {
    const orderId = crypto.randomUUID();
    return { id: orderId, ...request.body };
  }
);

fastify.listen({ port: 3000 });
```

## API

### `idempotency(options)`

Creates Fastify preHandler hook for idempotency.

**Options:**

- `store` (required): Storage backend implementing `IdempotencyStore`
- `headerName`: Header name for idempotency key (default: `"Idempotency-Key"`)
- `required`: Whether idempotency key is required (default: `false`)
- `ttlMs`: Time-to-live for idempotency records in milliseconds
- `excludeFields`: Fields to exclude from fingerprint calculation
- `resilience`: Circuit breaker and retry options

**Returns:** Fastify preHandler hook function with `circuit` property for monitoring.

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { idempotency } from "@idempot/fastify-middleware";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/hono-middleware
Description: Hono middleware for idempotency
Latest version: 1.2.0

# @idempot/hono-middleware

Hono middleware for idempotency.

## Installation

```bash
npm install @idempot/hono-middleware
```

### Available Stores

Choose a storage backend that fits your infrastructure:

- `@idempot/sqlite-store` - great for development and single-node deployments
- `@idempot/redis-store`
- `@idempot/postgres-store`
- `@idempot/mysql-store`
- `@idempot/bun-sql-store` - Bun runtime

## Usage

```javascript
import { Hono } from "hono";
import { idempotency } from "@idempot/hono-middleware";
import { SqliteIdempotencyStore } from "@idempot/sqlite-store";

const app = new Hono();
const store = new SqliteIdempotencyStore({ path: ":memory:" });

app.post("/orders", idempotency({ store }), async (c) => {
  const orderId = crypto.randomUUID();
  return c.json({ id: orderId, ...(await c.req.json()) }, 201);
});

export default app;
```

## API

### `idempotency(options)`

Creates Hono middleware for idempotency.

**Options:**

- `store` (required): Storage backend implementing `IdempotencyStore`
- `headerName`: Header name for idempotency key (default: `"Idempotency-Key"`)
- `required`: Whether idempotency key is required (default: `false`)
- `ttlMs`: Time-to-live for idempotency records in milliseconds
- `excludeFields`: Fields to exclude from fingerprint calculation
- `resilience`: Circuit breaker and retry options

**Returns:** Hono middleware function with `circuit` property for monitoring.

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { idempotency } from "@idempot/hono-middleware";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/postgres-store
Description: PostgreSQL storage backend for idempotency
Latest version: 1.0.3

# @idempot/postgres-store

PostgreSQL storage backend for idempotency.

## Installation

```bash
npm install @idempot/postgres-store pg
```

## Usage

```javascript
import { PostgresIdempotencyStore } from "@idempot/postgres-store";
import { Pool } from "pg";

const pool = new Pool({
  host: "localhost",
  database: "myapp",
  user: "postgres",
  password: "postgres"
});

const store = new PostgresIdempotencyStore({ pool });

// Close on shutdown
process.on("SIGINT", async () => {
  await store.close();
  process.exit(0);
});
```

## Schema

The store creates a table named `idempotency_records` with:

- `key` (TEXT, PRIMARY KEY)
- `fingerprint` (TEXT, indexed)
- `status` (TEXT: 'processing' or 'complete')
- `response_status` (INTEGER)
- `response_headers` (JSONB)
- `response_body` (TEXT)
- `expires_at` (TIMESTAMP, indexed)

## API

### `new PostgresIdempotencyStore(options)`

Creates a new PostgreSQL store.

**Options:**

- `pool`: PostgreSQL connection pool (from `pg` package)

### `store.lookup(key, fingerprint)`

Look up an idempotency record by key and fingerprint. Returns `{byKey, byFingerprint}`.

### `store.startProcessing(key, fingerprint, ttlMs)`

Mark a request as being processed. Creates a new record with status `'processing'`.

### `store.complete(key, response)`

Mark a request as complete with its response data. Updates the record with status `'complete'`.

### `store.close()`

Close the connection pool.

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { PostgresIdempotencyStore } from "@idempot/postgres-store";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/redis-store
Description: Redis storage backend for idempotency
Latest version: 1.0.3

# @idempot/redis-store

Redis storage backend for idempotency.

## Installation

```bash
npm install @idempot/redis-store ioredis
```

## Usage

```javascript
import { RedisIdempotencyStore } from "@idempot/redis-store";
import Redis from "ioredis";

const redis = new Redis();
const store = new RedisIdempotencyStore({ client: redis });

// Or with prefix
const store = new RedisIdempotencyStore({
  client: redis,
  prefix: "myapp:idempotency:"
});

// Close on shutdown
process.on("SIGINT", async () => {
  await store.close();
  process.exit(0);
});
```

## API

### `new RedisIdempotencyStore(options)`

Creates a new Redis store.

**Options:**

- `client`: Redis client instance (ioredis)
- `prefix`: Key prefix (default: `"idempotency:"`)

### `store.lookup(key, fingerprint)`

Look up an idempotency record by key and fingerprint. Returns `{byKey, byFingerprint}`.

### `store.startProcessing(key, fingerprint, ttlMs)`

Mark a request as being processed. Creates a new record with status `'processing'`.

### `store.complete(key, response)`

Mark a request as complete with its response data. Updates the record with status `'complete'`.

### `store.close()`

Close the Redis connection.

## Persistence

Ensure Redis persistence is configured (AOF strongly recommended). See [Redis persistence](https://redis.io/docs/latest/operate/oss_and_stack/management/persistence/).

## Deno Support

For Deno, use `DenoRedisIdempotencyStore`:

```javascript
import { DenoRedisIdempotencyStore } from "@idempot/redis-store/deno-redis.js";

const store = new DenoRedisIdempotencyStore({
  hostname: "127.0.0.1",
  port: 6379
});
```

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { RedisIdempotencyStore } from "@idempot/redis-store";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause
npm package: @idempot/sqlite-store
Description: SQLite storage backend for idempotency
Latest version: 1.0.3

# @idempot/sqlite-store

SQLite storage backend for idempotency.

## Installation

```bash
npm install @idempot/sqlite-store better-sqlite3
```

## Usage

```javascript
import { SqliteIdempotencyStore } from "@idempot/sqlite-store";

// In-memory (development)
const store = new SqliteIdempotencyStore({ path: ":memory:" });

// Persistent file
const store = new SqliteIdempotencyStore({ path: "./idempotency.db" });

// Close on shutdown
process.on("SIGINT", () => {
  store.close();
  process.exit(0);
});
```

## API

### `new SqliteIdempotencyStore(options)`

Creates a new SQLite store.

**Options:**

- `path`: Database path (default: `"./idempotency.db"`, use `":memory:"` for in-memory)

### `store.lookup(key, fingerprint)`

Look up an idempotency record by key and fingerprint. Returns `{byKey, byFingerprint}`.

### `store.startProcessing(key, fingerprint, ttlMs)`

Mark a request as being processed. Creates a new record with status `'processing'`.

### `store.complete(key, response)`

Mark a request as complete with its response data. Updates the record with status `'complete'`.

### `store.close()`

Close the database connection. Call this on shutdown.

## Deno Support

For Deno, use `DenoSqliteIdempotencyStore`:

```javascript
import { DenoSqliteIdempotencyStore } from "@idempot/sqlite-store/deno-sqlite.js";

const store = new DenoSqliteIdempotencyStore({ path: "./idempotency.db" });
```

## TypeScript Support

This library uses JavaScript with JSDoc comments for type information. Enable `allowJs` in your TypeScript configuration to use these types directly—no separate .d.ts files needed.

To use this library in a TypeScript project:

1. Add these settings to your `tsconfig.json`:

   ```json
   {
     "allowJs": true,
     "checkJs": true
   }
   ```

2. Import the library as you normally would:

   ```typescript
   import { SqliteIdempotencyStore } from "@idempot/sqlite-store";
   ```

3. JSDoc comments provide full type safety: parameter types, return types, and detailed documentation in your IDE.

This approach simplifies maintenance while giving TypeScript users an excellent developer experience.

## License

BSD-3-Clause