{"id":47819153,"url":"https://github.com/idempot-dev/idempot-js","last_synced_at":"2026-04-29T13:01:51.885Z","repository":{"id":348454710,"uuid":"1182628485","full_name":"idempot-dev/idempot-js","owner":"idempot-dev","description":"Idempotency middleware for Express, Fastify and Hono","archived":false,"fork":false,"pushed_at":"2026-04-27T20:24:36.000Z","size":1808,"stargazers_count":4,"open_issues_count":7,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-27T22:10:42.852Z","etag":null,"topics":["express","express-middleware","fastify","hono","idempotency","idempotency-key","idempotent","javascript","middleware"],"latest_commit_sha":null,"homepage":"https://js.idempot.dev","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/idempot-dev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":"mroderick","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":"gh/mroderick","custom":null}},"created_at":"2026-03-15T19:13:02.000Z","updated_at":"2026-04-27T20:24:38.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/idempot-dev/idempot-js","commit_stats":null,"previous_names":["idempot-dev/idempot-js"],"tags_count":59,"template":false,"template_full_name":null,"purl":"pkg:github/idempot-dev/idempot-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idempot-dev%2Fidempot-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idempot-dev%2Fidempot-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idempot-dev%2Fidempot-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idempot-dev%2Fidempot-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/idempot-dev","download_url":"https://codeload.github.com/idempot-dev/idempot-js/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/idempot-dev%2Fidempot-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32426588,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T12:24:25.982Z","status":"ssl_error","status_checked_at":"2026-04-29T12:24:24.439Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","express-middleware","fastify","hono","idempotency","idempotency-key","idempotent","javascript","middleware"],"created_at":"2026-04-03T19:01:36.925Z","updated_at":"2026-04-29T13:01:51.879Z","avatar_url":"https://github.com/idempot-dev.png","language":"JavaScript","funding_links":["https://github.com/sponsors/mroderick","https://thanks.dev/gh/mroderick"],"categories":[],"sub_categories":[],"readme":"# idempot\n\nIdempotency middleware for Hono, Express, and Fastify.\n\n## Features\n\n- Implements the IETF draft [draft-ietf-httpapi-idempotency-key-header-07](https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-idempotency-key-header-07) specification\n- Request fingerprinting for conflict detection\n- Built-in resilience: retries, timeouts, circuit breaker\n- Modular packages reduce install time and dependencies\n\n## TypeScript Support\n\nThis library uses JavaScript with JSDoc comments for type information. Each package ships `.d.ts` declaration files generated from the JSDoc-annotated source.\nTypeScript picks them up automatically via the `types` field in each `package.json`.\n\n```typescript\nimport { idempotency } from \"@idempot/hono-middleware\";\n```\n\nThe declarations are generated at publish time to ensure types match the published version.\n\n## Supported Runtimes, Frameworks, and Stores\n\n| Category       | Options                                                             |\n| -------------- | ------------------------------------------------------------------- |\n| **Runtimes**   | Node.js, Bun, Deno (Lambda \u0026 Cloudflare Workers planned)            |\n| **Frameworks** | Express, Hono, Fastify, Bun Server                                  |\n| **Stores**     | Redis, PostgreSQL, MySQL, SQLite (DynamoDB \u0026 Cloudflare KV planned) |\n\n## Response Headers\n\nDuplicate requests return cached responses with `x-idempotent-replayed: true`.\n\n## Error Responses (RFC 9457)\n\nError responses follow [RFC 9457](https://datatracker.ietf.org/doc/html/rfc9457) (Problem Details for HTTP APIs) and include:\n\n- `type` - URI identifying the problem type\n- `title` - Short human-readable summary\n- `detail` - Detailed explanation\n- `status` - HTTP status code\n- `instance` - Unique identifier for this error occurrence\n- `retryable` - Whether retrying might succeed\n- `idempotency_key` - The idempotency key from the request (when applicable)\n\n### Content Negotiation\n\nThe middleware supports content negotiation via the `Accept` header:\n\n**Default (application/problem+json):**\n\n```bash\ncurl -X POST http://localhost:3000/orders \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"item\": \"widget\"}'\n```\n\nResponse:\n\n```json\n{\n  \"type\": \"https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-idempotency-key-header-07#section-2.1\",\n  \"title\": \"Idempotency-Key is missing\",\n  \"detail\": \"This operation is idempotent and it requires correct usage of Idempotency Key.\",\n  \"status\": 400,\n  \"instance\": \"urn:uuid:550e8400-e29b-41d4-a716-446655440000\",\n  \"retryable\": false\n}\n```\n\n**Markdown format (for AI agents):**\n\n```bash\ncurl -X POST http://localhost:3000/orders \\\n  -H \"Accept: text/markdown\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"item\": \"widget\"}'\n```\n\nResponse:\n\n```markdown\n---\ntype: \"https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-idempotency-key-header-07#section-2.1\"\nstatus: 400\ninstance: \"urn:uuid:550e8400-e29b-41d4-a716-446655440000\"\nretryable: false\n---\n\n# Idempotency-Key is missing\n\n## What Happened\n\nThis operation is idempotent and it requires correct usage of Idempotency Key.\n\n## What You Should Do\n\n**Correct the issue.** This error requires changes to your request. Do not retry with the same idempotency key until the issue is resolved.\n```\n\nThe markdown format includes YAML frontmatter with all error fields and human-readable guidance for AI agents.\n\n## Quick Start\n\n```bash\nnpm install @idempot/hono-middleware @idempot/sqlite-store\n```\n\n```javascript\nimport { Hono } from \"hono\";\nimport { idempotency } from \"@idempot/hono-middleware\";\nimport { SqliteIdempotencyStore } from \"@idempot/sqlite-store\";\n\nconst app = new Hono();\nconst store = new SqliteIdempotencyStore({ path: \":memory:\" });\n\napp.post(\"/orders\", idempotency({ store }), async (c) =\u003e {\n  return c.json({ id: \"order-123\" }, 201);\n});\n```\n\n## Configuration\n\nThe middleware accepts an options object with the following properties:\n\n| Option          | Type               | Default               | Description                                          |\n| --------------- | ------------------ | --------------------- | ---------------------------------------------------- |\n| `store`         | `IdempotencyStore` | required              | Storage backend (Redis, PostgreSQL, MySQL, SQLite)   |\n| `required`      | `boolean`          | `true`                | Whether the `Idempotency-Key` header is required     |\n| `ttlMs`         | `number`           | `86400000` (24 hours) | Time-to-live for idempotency records in milliseconds |\n| `minKeyLength`  | `number`           | `21`                  | Minimum length for idempotency keys                  |\n| `maxKeyLength`  | `number`           | `255`                 | Maximum length for idempotency keys                  |\n| `excludeFields` | `string[]`         | `[]`                  | Body fields to exclude from request fingerprint      |\n| `resilience`    | `object`           | see below             | Circuit breaker and retry configuration              |\n\n**Resilience options:**\n\n| Option                     | Type     | Default | Description                              |\n| -------------------------- | -------- | ------- | ---------------------------------------- |\n| `timeoutMs`                | `number` | `500`   | Timeout per store operation              |\n| `maxRetries`               | `number` | `3`     | Retry attempts for failed operations     |\n| `retryDelayMs`             | `number` | `100`   | Delay between retries                    |\n| `errorThresholdPercentage` | `number` | `50`    | Error rate to trigger circuit breaker    |\n| `resetTimeoutMs`           | `number` | `30000` | Time before testing recovery             |\n| `volumeThreshold`          | `number` | `10`    | Minimum requests before circuit can open |\n\n**Example with custom configuration:**\n\n```javascript\napp.post(\n  \"/orders\",\n  idempotency({\n    store,\n    ttlMs: 7 * 24 * 60 * 60 * 1000, // 7 days\n    excludeFields: [\"timestamp\", \"$.metadata.requestId\"],\n    resilience: {\n      timeoutMs: 1000,\n      maxRetries: 5\n    }\n  }),\n  handler\n);\n```\n\nMonitor circuit breaker state:\n\n```javascript\nconst middleware = idempotency({ store });\nconsole.log(middleware.circuit.status); // 'closed', 'open', or 'half-open'\n```\n\nSee the [full configuration guide](https://js.idempot.dev/guide/configuration) for detailed documentation.\n\n## Examples\n\nSee the `examples/` directory for complete examples.\n\n## Changelog\n\nSee [GitHub Releases](https://github.com/idempot-dev/idempot-js/releases) for the changelog.\n\n## License\n\nBSD-3\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidempot-dev%2Fidempot-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fidempot-dev%2Fidempot-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fidempot-dev%2Fidempot-js/lists"}