open-index/open-npm huggingface dataset:
npm package: @oncely/express
Description: Express middleware for oncely idempotency
Author: stacks0x
Latest version: 1.0.3

# @oncely/express

Express middleware for HTTP idempotency.

[![npm version](https://img.shields.io/npm/v/@oncely/express.svg)](https://www.npmjs.com/package/@oncely/express)

## Installation

```bash
npm install @oncely/core @oncely/express
```

## Quick Start

```typescript
import express from 'express';
import { express as idempotent } from '@oncely/express';

const app = express();
app.use(express.json());

// Zero-config: memory storage, 24h TTL
app.post('/orders', idempotent(), async (req, res) => {
  const order = await createOrder(req.body);
  res.status(201).json(order);
});
```

## Configuration

```typescript
app.post(
  '/payments',
  idempotent({
    storage: redis(), // Storage adapter
    ttl: '1h', // Cache duration
    required: true, // Require Idempotency-Key header
    methods: ['POST', 'PUT'], // HTTP methods to protect
    failOpen: true, // Continue if storage fails
    getKey: (req) => req.headers['x-request-id'], // Custom key extraction
    getHash: (req) => hashObject(req.body), // Custom hash function
    onHit: (key, response) => {}, // Cache hit callback
    onMiss: (key) => {}, // Cache miss callback
    onError: (key, error) => {}, // Error callback
  }),
  handler
);
```

## Pre-configured Factory

Share configuration across routes:

```typescript
import { configure } from '@oncely/express';
import { redis } from '@oncely/redis';

const idempotent = configure({
  storage: redis(),
  ttl: '1h',
});

app.post('/orders', idempotent(), orderHandler);
app.post('/payments', idempotent({ required: true }), paymentHandler);
```

## Headers

| Header               | Direction | Description                           |
| -------------------- | --------- | ------------------------------------- |
| `Idempotency-Key`    | Request   | Client-provided unique key            |
| `Idempotency-Key`    | Response  | Echo of the key used                  |
| `Idempotency-Replay` | Response  | `true` when returning cached response |

## Error Responses

All errors follow [RFC 7807 Problem Details](https://tools.ietf.org/html/rfc7807):

| Status | Type           | Cause                               |
| ------ | -------------- | ----------------------------------- |
| 400    | `key-required` | Missing key when `required: true`   |
| 409    | `conflict`     | Request with same key in progress   |
| 422    | `mismatch`     | Same key reused with different body |

```json
{
  "type": "https://oncely.dev/errors/conflict",
  "title": "Conflict",
  "status": 409,
  "detail": "A request with this idempotency key is already being processed"
}
```

## With Redis

```typescript
import { redis } from '@oncely/redis';

app.post('/orders', idempotent({ storage: redis() }), handler);
```

## License

MIT
npm package: @oncely/next
Description: Next.js integration for oncely idempotency
Author: stacks0x
Latest version: 1.0.3

# @oncely/next

Next.js integration for HTTP idempotency. Supports App Router and Pages Router.

[![npm version](https://img.shields.io/npm/v/@oncely/next.svg)](https://www.npmjs.com/package/@oncely/next)

## Installation

```bash
npm install @oncely/core @oncely/next
```

## App Router

```typescript
// app/api/orders/route.ts
import { next } from '@oncely/next';

export const POST = next()(async (req) => {
  const order = await createOrder(await req.json());
  return Response.json(order, { status: 201 });
});
```

## Pages Router

```typescript
// pages/api/orders.ts
import { pages } from '@oncely/next/pages';

export default pages()(async (req, res) => {
  const order = await createOrder(req.body);
  res.status(201).json(order);
});
```

## Configuration

Both `next()` and `pages()` accept the same options:

```typescript
export const POST = next({
  storage: upstash(), // Storage adapter
  ttl: '1h', // Cache duration
  required: true, // Require Idempotency-Key header
  failOpen: true, // Continue if storage fails
  getKey: (req) => req.headers.get('x-request-id'), // Custom key extraction
  getHash: async (req) => hashObject(await req.json()), // Custom hash
  onHit: (key, response) => {}, // Cache hit callback
  onMiss: (key) => {}, // Cache miss callback
  onError: (key, error) => {}, // Error callback
})(handler);
```

## Pre-configured Factory

Share configuration across routes:

```typescript
// lib/idempotency.ts
import { configure } from '@oncely/next';
import { upstash } from '@oncely/upstash';

export const idempotent = configure({
  storage: upstash(),
  ttl: '1h',
});

// app/api/orders/route.ts
import { idempotent } from '@/lib/idempotency';

export const POST = idempotent()(handler);
```

Pages Router has its own configure:

```typescript
// lib/idempotency.ts
import { configure } from '@oncely/next/pages';

export const idempotent = configure({
  storage: upstash(),
  ttl: '1h',
});

// pages/api/orders.ts
import { idempotent } from '@/lib/idempotency';

export default idempotent()(handler);
```

## Headers

| Header               | Direction | Description                           |
| -------------------- | --------- | ------------------------------------- |
| `Idempotency-Key`    | Request   | Client-provided unique key            |
| `Idempotency-Key`    | Response  | Echo of the key used                  |
| `Idempotency-Replay` | Response  | `true` when returning cached response |

## Error Responses

All errors follow [RFC 7807 Problem Details](https://tools.ietf.org/html/rfc7807):

| Status | Type           | Cause                               |
| ------ | -------------- | ----------------------------------- |
| 400    | `key-required` | Missing key when `required: true`   |
| 409    | `conflict`     | Request with same key in progress   |
| 422    | `mismatch`     | Same key reused with different body |

## With Upstash (Serverless)

```typescript
import { upstash } from '@oncely/upstash';

export const POST = next({ storage: upstash() })(handler);
```

## License

MIT
npm package: @oncely/redis
Description: Redis storage adapter for oncely idempotency - works with ioredis
Author: stacks0x
Latest version: 1.0.0

# @oncely/redis

Redis storage adapter for oncely using ioredis.

[![npm version](https://img.shields.io/npm/v/@oncely/redis.svg)](https://www.npmjs.com/package/@oncely/redis)

## Installation

```bash
npm install @oncely/core @oncely/redis ioredis
```

## Quick Start

```typescript
import { redis } from '@oncely/redis';
import { express as idempotent } from '@oncely/express';

// From environment variable (ONCELY_REDIS_URL)
app.post('/orders', idempotent({ storage: redis() }), handler);
```

## Configuration

```typescript
import { redis } from '@oncely/redis';

// From environment variable
const storage = redis();

// From URL (password in URL)
const storage = redis('redis://:password@localhost:6379');

// With options
const storage = redis({
  url: 'redis://localhost:6379',
  keyPrefix: 'myapp:idem:',
});

// With existing ioredis client
import Redis from 'ioredis';
const client = new Redis({ host: 'localhost', password: 'secret' });
const storage = redis({ client });
```

## Environment Variables

| Variable           | Description                                                |
| ------------------ | ---------------------------------------------------------- |
| `ONCELY_REDIS_URL` | Redis connection URL (e.g., `redis://:password@host:6379`) |

## Redis Cluster

```typescript
import Redis from 'ioredis';
import { redis } from '@oncely/redis';

const cluster = new Redis.Cluster([
  { host: 'node1.example.com', port: 6379 },
  { host: 'node2.example.com', port: 6379 },
]);

const storage = redis({ client: cluster });
```

## AWS ElastiCache

```typescript
const storage = redis('redis://your-cluster.cache.amazonaws.com:6379');
```

## Usage with Express

```typescript
import { express as idempotent, configure } from '@oncely/express';
import { redis } from '@oncely/redis';

const idempotent = configure({
  storage: redis(),
  ttl: '1h',
});

app.post('/orders', idempotent(), orderHandler);
app.post('/payments', idempotent({ required: true }), paymentHandler);
```

## Usage with Next.js

```typescript
import { next } from '@oncely/next';
import { redis } from '@oncely/redis';

export const POST = next({ storage: redis() })(handler);
```

## Key Prefix

All keys are prefixed with `oncely:` by default. Customize with:

```typescript
const storage = redis({ keyPrefix: 'myapp:idem:' });
```

## License

MIT
npm package: @oncely/upstash
Description: Upstash Redis adapter for oncely idempotency
Author: stacks0x
Latest version: 1.0.3

# @oncely/upstash

Upstash Redis adapter for oncely. HTTP-based, perfect for serverless and edge.

[![npm version](https://img.shields.io/npm/v/@oncely/upstash.svg)](https://www.npmjs.com/package/@oncely/upstash)

## Installation

```bash
npm install @oncely/core @oncely/upstash
```

## Quick Start

```typescript
import { upstash } from '@oncely/upstash';
import { next } from '@oncely/next';

// From environment variables
export const POST = next({ storage: upstash() })(handler);
```

## Configuration

```typescript
import { upstash } from '@oncely/upstash';

// From environment variables (ONCELY_UPSTASH_REST_URL, ONCELY_UPSTASH_REST_TOKEN)
const storage = upstash();

// With explicit credentials
const storage = upstash({
  url: 'https://your-redis.upstash.io',
  token: 'your-rest-token',
});

// With options
const storage = upstash({
  url: process.env.UPSTASH_REDIS_REST_URL,
  token: process.env.UPSTASH_REDIS_REST_TOKEN,
  keyPrefix: 'myapp:idem:',
});

// With existing @upstash/redis client
import { Redis } from '@upstash/redis';
const client = new Redis({ url: '...', token: '...' });
const storage = upstash({ client });
```

## Environment Variables

| Variable                    | Description                                            |
| --------------------------- | ------------------------------------------------------ |
| `ONCELY_UPSTASH_REST_URL`   | Upstash REST endpoint (e.g., `https://xyz.upstash.io`) |
| `ONCELY_UPSTASH_REST_TOKEN` | Upstash REST token                                     |

## Usage with Next.js App Router

```typescript
// app/api/orders/route.ts
import { next } from '@oncely/next';
import { upstash } from '@oncely/upstash';

export const POST = next({ storage: upstash() })(async (req) => {
  const order = await createOrder(await req.json());
  return Response.json(order, { status: 201 });
});
```

## Usage with Next.js Pages Router

```typescript
// pages/api/orders.ts
import { pages } from '@oncely/next/pages';
import { upstash } from '@oncely/upstash';

export default pages({ storage: upstash() })(async (req, res) => {
  const order = await createOrder(req.body);
  res.status(201).json(order);
});
```

## Pre-configured Factory

```typescript
// lib/idempotency.ts
import { configure } from '@oncely/next';
import { upstash } from '@oncely/upstash';

export const idempotent = configure({
  storage: upstash(),
  ttl: '1h',
});

// app/api/orders/route.ts
import { idempotent } from '@/lib/idempotency';

export const POST = idempotent()(handler);
```

## Vercel KV

Vercel KV is compatible with Upstash. Use the Vercel KV environment variables:

```typescript
const storage = upstash({
  url: process.env.KV_REST_API_URL,
  token: process.env.KV_REST_API_TOKEN,
});
```

## Key Prefix

All keys are prefixed with `oncely:` by default. Customize with:

```typescript
const storage = upstash({ keyPrefix: 'myapp:idem:' });
```

## License

MIT
npm package: @onchain-id/claim-generators
Description: Generate and parse standard claims.
Author: OnchainID Organization
Latest version: 0.1.1-beta

Claim Generators for Onchain🆔 standard Identities.

Generate and parse standard claims for blockchain Identities.

# Usage

## Installation

Install with `yarn install @onchain-id/claim-generators`.

## Features

### Version

The package exposes its current version in the default export.

```typescript
import Package from "@onchain-id/claim-generators";

console.log(Package.version);
```