open-index/open-npm huggingface dataset:
npm package: @moksh05/tiny-rate-limiter
Description: A lightweight and extensible multi-algorithm rate limiter for Node.js and Express.
Author: Moksh Jain
Latest version: 1.0.2

# Tiny Rate Limiter

A powerful, highly structured, and extensible rate limiting package for Node.js and Express.

## Features

- **5 Rate Limiting Algorithms**:
  - `fixed-window`: Simple and efficient.
  - `sliding-window-log`: Most accurate, prevents bursts.
  - `sliding-window-counter`: Smooth transitions between windows.
  - `token-bucket`: Supports bursts with a steady refill rate.
  - `leaky-bucket`: Smooths out request processing.
- **2 Storage Strategies**:
  - `memory`: Local in-memory storage (Map-based).
  - `redis`: Distributed storage using Redis (powered by `ioredis`).
- **Flexible Key Generation**:
  - Limit by IP Address, UserID, API Key, or a custom function.
- **Customizable**:
  - Custom error messages and status codes.
  - Full TypeScript support.

## Installation

```bash
npm install tiny-rate-limiter
```

## Usage

### Simple Example (Fixed Window, IP-based)

```javascript
const express = require('express');
const { createRateLimiter } = require('tiny-rate-limiter');

const app = express();

const limiter = createRateLimiter({
  windowMs: 60 * 1000, // 1 minute
  limit: 100, // 100 requests per minute
  algorithm: 'fixed-window',
  storage: 'memory',
  keyGenerator: 'ip'
});

app.use(limiter);

app.get('/', (req, res) => {
  res.send('Hello World!');
});

app.listen(3000);
```

### Redis (Distributed) Example

```javascript
const limiter = createRateLimiter({
  windowMs: 15 * 60 * 1000,
  limit: 50,
  algorithm: 'token-bucket',
  storage: 'redis',
  redisUrl: 'redis://localhost:6379',
  keyGenerator: 'apikey'
});
```

### Custom Key Generator

```javascript
const limiter = createRateLimiter({
  windowMs: 60 * 1000,
  limit: 10,
  algorithm: 'sliding-window-counter',
  storage: 'memory',
  keyGenerator: (req) => req.headers['x-client-id']
});
```

## Configuration Options

| Option | Type | Description |
| --- | --- | --- |
| `windowMs` | `number` | Time window in milliseconds. |
| `limit` | `number` | Maximum number of requests within the window. |
| `algorithm` | `string` | `fixed-window`, `sliding-window-log`, `sliding-window-counter`, `token-bucket`, `leaky-bucket`. |
| `storage` | `string` | `memory` or `redis`. |
| `redisUrl` | `string` | Required if storage is `redis`. |
| `keyGenerator` | `string \| function` | `ip`, `userid`, `apikey`, or a custom function `(req) => string`. |
| `message` | `string` | Custom error message (optional). |
| `statusCode` | `number` | Custom status code (default 429). |

## License

MIT
npm package: @mokup/cli
Description: CLI for building mokup manifests and handlers.
Latest version: 2.0.0

# @mokup/cli

[English](./README.md) | 中文

## 概览

本包提供 Mokup CLI 使用的 manifest 构建 API。`mokup` 命令由 `mokup` 包提供。
完整文档见 https://mokup.icebreaker.top。

## 环境要求

- Node.js `^20.19.0 || >=22.12.0`

## 升级提示

- 该包现在只提供 ESM 输出。
- 完整迁移说明见：[../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)
npm package: @mokup/client
Description: Client-side request switching and adapters for mokup.
Latest version: 1.0.0

# @mokup/client

Client-side request switching utilities and adapters for Mokup.

## Requirements

- Node.js `^20.19.0 || >=22.12.0`

## Upgrade notes

- This package now ships ESM-only output.
- Full migration guide: [../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)

## Install

```bash
pnpm add @mokup/client
```

## Quick start (fetch)

```ts
import { createFetchAdapter, createMockResolver } from '@mokup/client'

const resolver = createMockResolver({
  mockBase: 'http://localhost:3300',
  realBase: 'https://api.example.com',
  pathMap: [{ from: '/api/*', to: '/*' }],
  markers: { header: true },
})

const mokupFetch = createFetchAdapter({ resolver })

await mokupFetch('/api/users', { mock: true })
```

## Quick start (axios)

```ts
import { applyMokupToAxios } from '@mokup/client'
import axios from 'axios'

const api = axios.create({ baseURL: 'https://api.example.com' })

applyMokupToAxios(api, {
  resolverOptions: {
    mockBase: 'http://localhost:3300',
    realBase: 'https://api.example.com',
    pathMap: [{ from: '/api/*', to: '/*' }],
  },
})

await api.request({ url: '/api/users', mock: true })
```

## Resolver options

- `mockBase`: mock server origin or base path
- `realBase`: real API origin or base path
- `pathMap`: prefix rewrite rules (`/api/* -> /*`)
- `allowHosts`: only rewrite matching hosts
- `markers`: inject headers or query markers (`x-mokup`, `__mokup`)
- `storage`: persist global toggle (optional)

## Overrides and priority

Order (highest to lowest):

1. Request `mock` or `meta.mokup`
2. Headers/cookie/query markers
3. Global `setUseMock`
4. `resolverOptions.env.useMock`

## Global switch

```ts
const resolver = createMockResolver({ mockBase, realBase })
resolver.setUseMock(true)

const useMock = resolver.getUseMock()
```
npm package: @mokup/playground
Description: Static playground UI for mokup mock APIs.
Latest version: 1.0.0

# @mokup/playground

[English](./README.md) | 中文

## 概览

用于浏览、测试与调试 Mokup mock 路由的独立 UI。完整文档见 https://mokup.icebreaker.top。

## 环境要求

- Node.js `^20.19.0 || >=22.12.0`

## 升级提示

- 该包现在只提供 ESM 输出。
- 完整迁移说明见：[../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)
npm package: @mokup/query
Description: TanStack Query integrations for mokup client switching.
Latest version: 1.0.0

# @mokup/query

TanStack Query integrations for Mokup request switching.

## Requirements

- Node.js `^20.19.0 || >=22.12.0`

## Upgrade notes

- This package now ships ESM-only output.
- Full migration guide: [../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)

## Install

```bash
pnpm add @mokup/query @mokup/client
```

## Quick start (global defaults)

```ts
import { applyMokupToQueryClient } from '@mokup/query'
import { QueryClient } from '@tanstack/react-query'

const queryClient = new QueryClient()

applyMokupToQueryClient(queryClient, {
  resolverOptions: {
    mockBase: 'http://localhost:3300',
    realBase: 'https://api.example.com',
    pathMap: [{ from: '/api/*', to: '/*' }],
    markers: { header: true },
  },
})
```

## Query key convention

Default `queryKey` shapes:

```ts
const keyA = ['GET', '/users', { params, headers, body, mock: true }]
const keyB = ['/users', { params, mock: true }]
```

Per-request override using `meta`:

```ts
useQuery({
  queryKey: ['GET', '/users'],
  meta: { mokup: true },
})
```

If your app already has custom query keys, provide `buildRequest` to map them.

## Custom request mapping

```ts
import { createMokupQueryClient } from '@mokup/query'

const { queryFn, mutationFn } = createMokupQueryClient({
  buildRequest(queryKey, meta) {
    const [resource, params] = queryKey as [string, Record<string, unknown>?]
    return {
      url: resource,
      method: 'GET',
      params,
      meta,
    }
  },
})
```

## Using axios

```ts
import { applyMokupToQueryClient, createAxiosExecutor } from '@mokup/query'
import axios from 'axios'

const executor = createAxiosExecutor({
  axios,
  resolverOptions: {
    mockBase: 'http://localhost:3300',
    realBase: 'https://api.example.com',
  },
})

applyMokupToQueryClient(queryClient, { executor })
```

## Using fetch

```ts
import { applyMokupToQueryClient, createFetchExecutor } from '@mokup/query'

const executor = createFetchExecutor({
  resolverOptions: {
    mockBase: 'http://localhost:3300',
    realBase: 'https://api.example.com',
  },
})

applyMokupToQueryClient(queryClient, { executor })
```
npm package: @mokup/runtime
Description: Cross-runtime mock matching and response handling for mokup.
Latest version: 2.0.0

# @mokup/runtime

[English](./README.md) | 中文

## 概览

Mokup runtime 用于在请求时读取 manifest 并返回 mock 响应，是 Server 适配器与 Worker 的共享核心。完整文档见 https://mokup.icebreaker.top。

## 环境要求

- Node.js `^20.19.0 || >=22.12.0`

## 升级提示

- 该包现在只提供 ESM 输出。
- 完整迁移说明见：[../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)
npm package: @mokup/server
Description: Server adapters for @mokup/runtime.
Latest version: 2.0.0

# @mokup/server

[English](./README.md) | 中文

## 概览

Mokup 的 Server 适配器集合，用于把运行时接入各类 Node 框架与 Worker。完整文档见 https://mokup.icebreaker.top。

## 环境要求

- Node.js `^20.19.0 || >=22.12.0`

## 升级提示

- 该包现在只提供 ESM 输出。
- 完整迁移说明见：[../../docs/guide/migration-v1.md](../../docs/guide/migration-v1.md)

该包为 `mokup` 内部依赖，建议使用下方公开入口。

## 入口说明

- `mokup/server`：Node 适配器与开发服务器
- `mokup/server/node`：Node `serve` 入口
- `mokup/server/fetch`：运行时无关的 fetch 入口 + 类型
- `mokup/server/worker`：Worker helper，封装 `createFetchHandler` 并在 `null` 时返回 404
npm package: @mokup/shared
Description: Shared dependency exports for mokup.
Latest version: 2.0.0

# @mokup/shared

Shared utilities and public helper exports used across Mokup packages.

## Highlights

- Shared diagnostics helpers for route-scan and service worker conflict reporting.
- Shared filesystem, path, config, and module-loader helpers.
- The shared `rolldown` wrapper used by Mokup build tooling.

## Diagnostics helpers

```ts
import {
  collectRouteDiagnosticWarning,
  createRouteDiagnosticSections,
  reportDiagnostics,
} from '@mokup/shared/diagnostics'

const unsupportedFields = new Set<string>()
const missingHandlers = new Set<string>()
const duplicateRoutes = new Set<string>()

collectRouteDiagnosticWarning({
  message: 'Skip mock without handler: mock/users.get.ts',
  onUnsupportedFields: value => unsupportedFields.add(value),
  onMissingHandler: value => missingHandlers.add(value),
  onDuplicateRoute: value => duplicateRoutes.add(value),
})

const sections = createRouteDiagnosticSections({
  unsupportedFields: [...unsupportedFields],
  missingHandlers: [...missingHandlers],
  duplicateRoutes: [...duplicateRoutes],
})

const { error, summaryLines } = reportDiagnostics({
  sections,
  errorOn: ['missing-handler'],
})
```

For service worker diagnostics, reuse
`collectSwConflictDiagnosticWarning(...)` and
`createSwConflictDiagnosticSections(...)`.

## Common entries

- `@mokup/shared`
- `@mokup/shared/diagnostics`
- `@mokup/shared/rolldown`
- `@mokup/shared/logger`
- `@mokup/shared/module-loader`
- `@mokup/shared/pathe`

## Node.js

- `^20.19.0 || >=22.12.0`
npm package: @mokuteki/jwt
Description: Generate and decode JSON Web Tokens using symmetric or asymmetric hashing algorithms
Author: Vladyslav Kondratiuk
Latest version: 1.0.2

# @mokuteki/jwt
Zero dependency typescript friendly Node.js library designed to hash/decode JSON Web Tokens using symmetric/asymmetric algorithms

## Installation
```bash
npm i @mokuteki/jwt
```

## Quick start 

* Pick one hashing strategy out of existing ones
* Pass the strategy to JSONWebToken constructor
* Use created instance to generate/verify JWTs

## HS256 Strategy

```javascript
const { JSONWebToken, HS256Strategy } = require('@mokuteki/jwt');

const strategy = new HS256Strategy({
  ttl: 10000,
  secret: 'YOUR_SECRET',
});

const jwt = new JSONWebToken(strategy);
const payload = { id: 1 };

const token = jwt.generate(payload);
const decoded = jwt.verify(token);

console.log(decoded); // { id: 1 }
```

## RS256 Strategy

```javascript
const { JSONWebToken, RS256Strategy } = require('@mokuteki/jwt');

const strategy = new RS256Strategy({
  ttl: 10000,
  publicKey: 'YOUR_PUBLIC_KEY',
  privateKey: 'YOUR_PRIVATE_KEY',
});

const jwt = new JSONWebToken(strategy);
const payload = { id: 1 };

const token = jwt.generate(payload);
const decoded = jwt.verify(token);

console.log(decoded); // { id: 1 }
```

## Override predefined options

```javascript
const { JSONWebToken, HS256Strategy } = require('@mokuteki/jwt');

const strategy = new HS256Strategy({
  ttl: 10000,
  secret: 'YOUR_SECRET',
});

const jwt = new JSONWebToken(strategy);
const payload = { id: 1 };

/**
 * Override JWT ttl option
 */
const token = jwt.generate(payload, { ttl: 1000 });

setTimeout(() => {
  try {
    const decoded = jwt.verify(token);
  } catch (err) {
    // err instanceof JwtExpiredError
  }
}, 2000);
```

```javascript
const { JSONWebToken, HS256Strategy } = require('@mokuteki/jwt');

const strategy = new HS256Strategy({
  ttl: 10000,
  secret: 'YOUR_SECRET',
});

const jwt = new JSONWebToken(strategy);
const payload = { id: 1 };

const token = jwt.generate(payload, { ttl: 20000, secret: 'NEW_SECRET' });

try {
  const decoded = jwt.verify(token);
} catch (err) {
  // err instanceof InvalidSignatureError
}
```

## License
Licensed under [MIT](https://github.com/mokuteki225/jwt/blob/master/LICENSE.md)
npm package: @mokuton/gcm
Description: Library with components and utilities customized for use in gcm project (web).
Latest version: 2.2.3

# Components and utilities for Gcm projects (web)

Library with components and utilities customized for use in gcm project (web).

## Versions

`0.x` dev versions, only for tests.

`1.x` conflict with existent versions on deleted package, this version not exist here.

`2.x` you can use it in your projects.
npm package: @molaux/graphql-sequelize-r-react-admin
Description: a graphql-sequelize-r module that implements basic react-admin grammar
Author: Marc-Olivier Laux
Latest version: 2.0.0-alpha.2

# graphql-sequelize-r-react-admin

A [graphql-sequelize-r](https://github.com/molaux/graphql-sequelize-r) plugin that *partially* implements [ra-data-graphql-simple](https://github.com/marmelab/react-admin/tree/master/packages/ra-data-graphql-simple) grammar (a GraphQL data provider for [react-admin](https://github.com/marmelab/react-admin/)).

## Install

```bash
yarn add @molaux/graphql-sequelize-r-react-admin
```

## Use

```javascript
import graphqlSequelizeRReactAdmin from '@molaux/graphql-sequelize-r-react-admin'

const {
  extraModelFields: reactAdminFieldsGenerator,
  extraModelQueries: reactAdminQueriesGenerator,
  extraModelTypes: reactAdminTypesGenerator,
  extraTypes: reactAdminExtraTypes
} = graphqlSequelizeRReactAdmin
```
npm package: @molcay/jsctx
Description: A strictly typed context library for JavaScript / TypeScript projects.
Author: M. Olcay TERCANLI
Latest version: 0.3.1

# jsctx

`jsctx` is a package for creating a context for a flow like HTTP request, background jobs, etc.
Also, you can use this to pass data between function calls, use timers and log it as JSON format.

# Usage
```javascript
import { Context } from 'jsctx';

const ctx: Context = new Context();

// This set methods does not serialize, this is only for pass data between functions.
ctx
    .set('x', 1)
    .set('y', false)
    .set('z', '123');

const x = 100;
const y = (x + 1) * (x - 1);

ctx.log.setData('numbers/y', y);
ctx.log.setData('numbers/y.isEven', y % 2);

// The first way to using timer
const timer1 = ctx.log.startTimer('timer1');
setTimeout(() => {
    timer1.stop();
}, 1000);

// The second way to using timer
ctx.log.startTimer('timer2');
setTimeout(() => {
    const elapsedTime = ctx.log.stopTimer('timer2');
    ctx.log.setData('timer2/elapsedTime', elapsedTime);
}, 500);

// The third way to using timer (timer with sync function result)
const result = ctx.log.withTimer('timer3', () => {
    let sum = 0;
    for (let i = 1; i < 10000000; i++) {
        sum += i;
    }
    return sum;
});
ctx.log.setData('sum', result);

// The forth way to using timer (timer with async function result)
const result2 = await ctx.log.withTimerAsync('timer4', () => {
    return new Promise((resolve) => setTimeout(() => resolve('my result string'), 200));
});
ctx.log.setData('results/string', result2);

setTimeout(() => {
    // We are finalizing Context with timeout to see timers with setTimeouts
    console.log(JSON.stringify(ctx.finalize()));
}, 4000);
```

* The output will be:
```json
{
  "type": "CTX",
  "id": "bcbd45c1-7695-4b4f-acdb-6e3f0807ccf5",
  "startTime": "2022-08-20T21:20:44.156Z",
  "endTime": "2022-08-20T21:20:48.371Z",
  "data": {
    "numbers": {
      "y": 9999,
      "y.isEven": 1
    },
    "sum": 49999995000000,
    "results": {
      "string": "my result string"
    },
    "timer2": {
      "elapsedTime": 504
    }
  },
  "timers": {
    "timer3.s": {
      "sum": 11,
      "cnt": 1,
      "min": 11,
      "max": 11,
      "avg": 11
    },
    "timer4.s": {
      "sum": 202,
      "cnt": 1,
      "min": 202,
      "max": 202,
      "avg": 202
    },
    "timer2": {
      "sum": 504,
      "cnt": 1,
      "min": 504,
      "max": 504,
      "avg": 504
    },
    "timer1": {
      "sum": 1002,
      "cnt": 1,
      "min": 1002,
      "max": 1002,
      "avg": 1002
    },
    "ALL": {
      "sum": 4215,
      "cnt": 1,
      "min": 4215,
      "max": 4215,
      "avg": 4215
    }
  }
}
```