open-index/open-npm huggingface dataset:
npm package: @noga_test/hello-world-test
Description: A simple test package that returns 'Hello World'
Author: Noga
Latest version: 1.0.2

# Hello World Test Package

A simple npm package that returns 'Hello World'. This is a test package for learning how to publish to npm.

## Installation

```bash
npm install @noga_test/hello-world-test
```


## API

### `helloWorld()`

Returns the string `'Hello World'`.

**Returns:** `string` - The string 'Hello World'

## License

MIT
npm package: @nogataka/cc-search
Description: ![CC Search](docs/assets/screenshot001.png)
Latest version: 0.1.5

# CC Search

![CC Search](docs/assets/screenshot001.png)

**Claude Code** と **Codex** の会話ログを閲覧・検索できる統合ログビューアーです。

ローカルに保存されたセッションファイル（`~/.claude/projects/`、`~/.codex/sessions/`）を読み取り、プロジェクト単位・セッション単位で会話の内容を確認できます。

## クイックスタート

```bash
npx @nogataka/cc-search
```

これだけで起動します。ブラウザで http://localhost:5858 を開いてください。

> Node.js 20.12.0 以上が必要です。

## 主な機能

### プロジェクト一覧

- Claude Code / Codex をタブで切り替え
- プロジェクト名・パスでの検索フィルター
- ソート（最終更新日 / プロジェクト名 / セッション数）
- グリッド表示 / リスト表示の切り替え

### セッション一覧

- プロジェクト内のセッションをカード形式で表示
- フィルター設定（折りたたみ式）
  - ユーザーメッセージのないセッションを非表示
  - 同一タイトルのセッションを統合（最新のみ表示）
- Claude Code セッションはコスト・モデル名も表示

### セッション詳細

- **左サイドバー**: セッション一覧（ワンクリックで切り替え）、設定タブ
- **スティッキーヘッダー**: セッションタイトル、プロジェクトパス、セッションID（コピー可）、コスト・トークン情報
- **会話ビュー**: ユーザーメッセージ、アシスタント応答、ツール使用、思考ブロックを構造的に表示
- **フローティングボタン**: 会話の先頭 / 末尾へスクロール
- **モバイル対応**: レスポンシブデザイン、モバイル用サイドバー

### 全文検索

- Claude Code・Codex の全セッションを横断検索
- 検索対象ソースの選択（チェックボックス）
- マッチ箇所をハイライト表示
- 検索結果からセッション詳細へ直接ジャンプ

## セットアップ

### 必要なもの

- Node.js 20.12.0 以上
- pnpm 10.8.1

### インストール

```bash
git clone https://github.com/nogataka/cc-search.git
cd cc-search
pnpm install
```

### 開発サーバーの起動

```bash
pnpm dev
```

ブラウザで http://localhost:5858 を開きます。

### プロダクションビルド

```bash
pnpm build
pnpm start
```

## 読み取るデータ

CC Search は以下のディレクトリからセッションデータを読み取ります（読み取り専用）。

| ソース | パス |
|---|---|
| Claude Code | `~/.claude/projects/<projectId>/<sessionId>.jsonl` |
| Codex | `~/.codex/sessions/<workspacePath>/<sessionId>.jsonl` |

### Claude Code セッション

- JSONL 形式の会話ログ（user / assistant / system / summary）
- ツール使用（tool_use）、ツール結果（tool_result）、思考ブロック（thinking）を構造的にパース
- API コスト（USD）、トークン使用量（入力・出力・キャッシュ）、モデル名を自動集計

### Codex セッション

- JSONL 形式のターンベースログ
- ユーザーメッセージ、アシスタント応答、ツールコール・結果をペアリング表示
- XML コマンドペイロードのパース対応

## 設定

設定はブラウザの Cookie に保存され、セッション一覧ページやサイドバーの設定タブから変更できます。

| 設定項目 | デフォルト | 説明 |
|---|---|---|
| `hideNoUserMessageSession` | `true` | ユーザーメッセージのないセッションを非表示 |
| `unifySameTitleSession` | `true` | 同一タイトルのセッションを統合 |
| `enterKeyBehavior` | `shift-enter-send` | 送信キーの動作（`shift-enter-send` / `enter-send`） |

## 開発

```bash
# Lint
pnpm lint

# フォーマット＆Lint 自動修正
pnpm fix

# 型チェック
pnpm typecheck

# テスト
pnpm test
```

## 技術スタック

- **フレームワーク**: Next.js 15 (React 19, Turbopack)
- **API**: Hono + Zod バリデーション
- **状態管理**: TanStack React Query, Jotai
- **UI**: Tailwind CSS 4, Radix UI, Lucide Icons
- **Markdown**: react-markdown + remark-gfm + react-syntax-highlighter
- **ツール**: Biome (formatter/linter), Vitest, TypeScript

## ライセンス

MIT
npm package: @nogataka/cloud-code-switcher
Description: Switch Claude Code providers via CLI and Web UI
Latest version: 0.0.3

# cloud-code-switcher

Claude Code のプロバイダーを CLI / Web UI から切り替えるツールです。

![Cloud Code Switcher](docs/assets/screenshot.png)

## 対応プロバイダー

| ID | プロバイダー | 認証 |
|----|-------------|------|
| `claude` | Claude (Default) | 不要 |
| `azure` | Azure Anthropic (Foundry) | 必要 |
| `glm` | GLM (Zhipu AI) | 必要 |
| `ollama` | Ollama (Local) | 不要 |
| `kimi` | Kimi (Moonshot) | 必要 |
| `custom` | Custom Provider | 必要 |

## インストール

```bash
npm install -g cloud-code-switcher
```

## 使い方

### 現在の設定を表示

```bash
cc-switch show
```

```
provider: claude
default_tier: sonnet
model: claude-opus-4-1
model_opus: claude-opus-4-1
model_sonnet: claude-opus-4-1
model_haiku: claude-opus-4-1
base_url: -
auth: missing
updated_at: 2025-01-01T00:00:00.000Z
```

### シェル環境変数をエクスポート

```bash
eval "$(cc-switch env)"
```

現在の設定に基づいた `export` / `unset` コマンドを出力します。
`.bashrc` / `.zshrc` に追加すれば、シェル起動時に自動適用できます。

```bash
# ~/.bashrc or ~/.zshrc
eval "$(cc-switch env)"
```

### Web UI を起動

```bash
cc-switch ui
```

ブラウザが開き、GUI でプロバイダーやモデルを切り替えられます。

| 環境変数 | 説明 | デフォルト |
|---------|------|-----------|
| `CC_SWITCH_HOST` | リッスンアドレス | `127.0.0.1` |
| `CC_SWITCH_PORT` | リッスンポート | `8787` |

### プロバイダー環境で claude を起動

```bash
cc-switch run
```

設定済みの環境変数を付与して `claude` を起動します。
引数はそのまま `claude` に渡されます。

```bash
# claude を起動
cc-switch run

# オプション付きで起動
cc-switch run --dangerously-skip-permissions
cc-switch run --model sonnet
```

## 設定ファイル

状態は `~/.config/cloud-code-switcher/state.json` に保存されます。

```json
{
  "provider": "claude",
  "default_tier": "sonnet",
  "model": "claude-opus-4-1",
  "model_opus": "claude-opus-4-1",
  "model_sonnet": "claude-opus-4-1",
  "model_haiku": "claude-opus-4-1",
  "base_url": null,
  "auth_token": "",
  "updated_at": "2025-01-01T00:00:00.000Z"
}
```

## 開発

### セットアップ

```bash
# リポジトリをクローン
git clone https://github.com/your-name/cloud-code-switcher.git
cd cloud-code-switcher

# 依存関係のインストール
npm install

# ビルド (esbuild)
npm run build
```

### 開発時の実行方法

グローバルインストールせずにローカルで動作確認するには `npm run dev` を使います。
`cc-switch` コマンドの代わりに `npm run dev` の後にサブコマンドを指定してください。

```bash
# ヘルプを表示
npm run dev

# 現在の設定を表示
npm run dev show

# シェル環境変数をエクスポート
npm run dev env

# Web UI を起動
npm run dev ui

# プロバイダー環境で claude を起動
npm run dev run
npm run dev run -- --dangerously-skip-permissions
```

### プロジェクト構成

```
src/          TypeScript ソースコード
bin/          エントリポイント (bin/cc-switch.js)
dist/         ビルド出力 (esbuild)
static/       Web UI の静的ファイル
```

### 設定ファイルの場所

開発時もグローバルインストール時も、設定は同じパスに保存されます。

| ファイル | 内容 |
|---------|------|
| `~/.config/cloud-code-switcher/state.json` | プロバイダー設定・モデル情報 |
| `~/.config/cloud-code-switcher/processes.json` | `run` で起動したプロセスの管理 |

## ライセンス

MIT
npm package: @nogateui/button
Description: Beginner-friendly React button component
Latest version: 0.1.6

# @nogateui/button

A beginner-friendly, flexible React Button component.

This package is part of **NoGateUI**, an open-source React UI component ecosystem focused on making open source contributions accessible, welcoming, and practical.

---

## Why

Many developers want to contribute to open source but don’t know where to start or are afraid of getting things wrong.

NoGateUI exists to remove that fear.

This Button component is intentionally simple, real-world, and easy to understand. It’s designed as a safe entry point into open source while still being useful in production projects.

---

## Install

```bash
npm install @kendevelops/nogateui-button
```

---

## Usage

```tsx
import { Button } from "@kendevelops/nogateui-button";

<Button>Primary</Button>

<Button variant="outline">Outline</Button>

<Button variant="ghost">Ghost</Button>

<Button size="lg">Large Button</Button>

<Button loading>Loading...</Button>
```

---

## Props

| Prop     | Type                              | Default   | Description                             |
| -------- | --------------------------------- | --------- | --------------------------------------- |
| variant  | `primary` \| `outline` \| `ghost` | `primary` | Visual style of the button              |
| size     | `sm` \| `md` \| `lg`              | `md`      | Size of the button                      |
| loading  | `boolean`                         | `false`   | Shows loading state and disables button |
| disabled | `boolean`                         | `false`   | Disables the button                     |
| children | `ReactNode`                       | —         | Button content                          |

All native HTML button props are supported.

---

## Accessibility

- Uses native `<button>` element
- Supports disabled state
- Keyboard accessible by default

---

## Contributing

We operate with an approximate **95% pull request acceptance rate**.

This means we default to merging and improving together instead of rejecting contributions over small mistakes. If something isn’t perfect, we guide, iterate, and refactor openly.

This project is beginner-friendly by design, but experienced developers are also welcome to contribute, review code, and help shape the API.

If you’ve ever wanted to contribute to open source but didn’t know where to start, this is for you.

---

## Roadmap

- Hover and focus styles
- Animation variants
- Icon support
- Theme s
npm package: @nogateui/skeleton
Description: Beginner-friendly React Skeleton Loader component
Latest version: 0.1.8

# @nogateui/skeleton

A beginner-friendly React Skeleton Loader component.

## Why

Contributing to open source shouldn’t be hard, but for many people it is.

This package is part of **NoGateUI**, an open-source React UI library built to make contributing feel accessible, not intimidating. We prioritise learning, iteration, and collaboration over gatekeeping.

## Install

```bash
npm install @nogateui/skeleton
```

## Usage

```tsx
import { Skeleton } from "@nogateui/skeleton";

<Skeleton width={200} height={20} />
<Skeleton variant="circle" width={40} height={40} />
```

## Props

| Name    | Type                         | Default | Description            |
| ------- | ---------------------------- | ------- | ---------------------- |
| width   | number \| string             | "100%"  | Width of the skeleton  |
| height  | number \| string             | 16      | Height of the skeleton |
| variant | "text" \| "rect" \| "circle" | "text"  | Shape variant          |

## Contributing

We operate with an approximate **95% pull request acceptance rate**.

This means we default to merging and improving together instead of rejecting contributions over small mistakes. If something isn’t perfect, we guide, iterate, and refactor openly.

Contributions of any size are welcome. Beginners and experienced developers alike are encouraged to contribute.

## License

MIT
npm package: @nogsantos/commitlint-conf
Description: Shareble commitlint configuration
Author: Fabricio Nogueira
Latest version: 0.1.0

# @nogsantos/commitlint-conf

Shareable [`commitlint`](https://github.com/conventional-changelog/commitlint) configuration.

## Setup

### Installing

Install as development dependency

```bash
# npm
npm i -D @nogsantos/commitlint-conf

# yarn
yarn add -D @nogsantos/commitlint-conf
```

Apply the config to `commitlint`:

```sh
echo "module.exports = {extends: ['@nogsantos']};" > commitlint.config.js
```
npm package: @nogsantos/fn-cli
Description: CLI generators
Author: Fabricio Nogueira
Latest version: 0.2.0

# fn-cli

[![Travis](https://img.shields.io/travis/nogsantos/fn-cli.svg?style=flat-square)](https://travis-ci.org/nogsantos/fn-cli)
[![NPM version](https://img.shields.io/npm/v/@nogsantos/fn-cli.svg?style=flat-square)](https://www.npmjs.com/package/@nogsantos/fn-cli)
[![NPM downloads](https://img.shields.io/npm/dm/@nogsantos/fn-cli.svg?style=flat-square)](https://www.npmjs.com/package/@nogsantos/fn-cli)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://opensource.org/licenses/MIT)

CLI to get skeletons

## Install

If necessary use ```sudo```

```shell
npm i -g @nogsantos/fn-cli
```

## Run

### Generator

```shell
fn-cli g
```

Select the skeleton

![Select](https://res.cloudinary.com/nogsantos/image/upload/v1517511037/Screenshot_from_2018-02-01_16-45-25_eplold.png)

Fill in some informations

![Package info](https://res.cloudinary.com/nogsantos/image/upload/v1517511037/Screenshot_from_2018-02-01_16-45-56_erhv4b.png)

### Help

```shell
fn-cli help
```

[WIP]

![Help](https://res.cloudinary.com/nogsantos/image/upload/v1517511037/Screenshot_from_2018-02-01_16-45-04_eaa3sv.png)

## License

MIT © [Fabricio Nogueira](http://fabricionogueira.me)
npm package: @nogsantos/hash
Description: Sha1 and Md5 hash encoder for javascript
Author: Fabricio Nogueira
Latest version: 0.2.1

# @nogsantos/hash

[![Travis](https://img.shields.io/travis/nogsantos/hash.svg?style=flat-square)](https://travis-ci.org/nogsantos/hash)
[![NPM version](https://img.shields.io/npm/v/@nogsantos/hash.svg?style=flat-square)](https://www.npmjs.com/package/@nogsantos/hash)
[![NPM downloads](https://img.shields.io/npm/dm/@nogsantos/hash.svg?style=flat-square)](https://www.npmjs.com/package/@nogsantos/hash)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://opensource.org/licenses/MIT)

Sha1 and Md5 hash encoder for javascript.

## Install

```shell
npm i -P @nogsantos/hash
```

## Example of usage

### Web

```html
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

    <script src="./node_modules/@nogsantos/hash/dist/hash.umd.min.js"></script>
    <script>
        var md5 = new Hash.Md5();
        var md5Results = [
            {
                lorem: md5.encode('Lorem ipsum dolor sit, amet consectetur adipisicing elit. Perferendis, officia. Maxime, eveniet similique modi quia illo inventore nemo numquam ipsum quod amet veniam, ullam facere. Ullam esse odit laboriosam consectetur!'),
                test: md5.encode('test')
            }
        ];
        console.table(md5Results);

        var sha1 = new Hash.Sha1();
        var sha1Results = [
            {
                lorem: sha1.encode('Lorem ipsum dolor sit, amet consectetur adipisicing elit. Perferendis, officia. Maxime, eveniet similique modi quia illo inventore nemo numquam ipsum quod amet veniam, ullam facere. Ullam esse odit laboriosam consectetur!'),
                test: sha1.encode('test')
            }
        ];
        console.table(sha1Results);

    </script>
</body>

</html>

```

#### Output

![Console](https://res.cloudinary.com/nogsantos/image/upload/v1517849815/Screenshot_from_2018-02-05_14-53-31_qk4smh.png)

### Node

```javascript
const Md5 = require('@nogsantos/hash').Md5;
const Sha1 = require('@nogsantos/hash').Sha1;
// or just
// const { Md5, Sha1}  = require('@nogsantos/hash');

const md5 = new Md5();
console.log('md5: ', md5.encode('Lorem ipsum dolor sit, amet consectetur adipisicing elit.'));
console.log('md5: ', md5.encode('test'));

const sha1 = new Sha1();
console.log('sha1: ', sha1.encode('Lorem ipsum dolor sit, amet consectetur adipisicing elit.'));
console.log('sha1: ', sha1.encode('test'));

```

## License

MIT © [Fabricio Nogueira](http://fabricionogueira.me)
npm package: @nogsantos/js-base-lib
Description: Javascript base lib
Author: Fabricio Nogueira
Latest version: 0.1.0

# Js base lib

A base for js libs

## Setup

```bash
$ npm i
```

## Make

### development

To development environment, the navigator will open on `http://localhost:9000/`. Refresh the page to load the changes.

```bash
$ npm run make:dev
```

### dist

```bash
$ npm run make
```

## Publish

```bash
$ npm publish
```
npm package: @nogueiradev/nogdevtools
Description: Biblioteca utilitária para formatação e manipulação de dados em projetos Next.js e Node.
Author: Filipe Nogueira
Latest version: 1.2.5

# 🧰 nogDevTools

Biblioteca utilitária desenvolvida por **Nogueira Dev** para padronizar formatações e operações comuns em sistemas JavaScript/TypeScript — como formatação de CPF, CNPJ, CEP, telefones, datas, e valores monetários.

---

## 🚀 Instalação

Após publicar no npm, você poderá instalar com:

```bash
npm install @nogueiradev/nogdevtools
```
npm package: @nogw/custom-errors
Description: Powerful `fetch` wrapper with the given functionallies:
Latest version: 1.0.94

# Woovi apiWithLog

Powerful `fetch` wrapper with the given functionallies:

- log request and response when using env `DEBUG=true`
- save request when using env `WRITE_MOCK=true`
- reply request when using env `USE_MOCK=true`
- send error to slack and sentry based on your setup

## Usage

This will make the request but it won't show any logs

```bash
yarn es scripts/test.ts 
```

Show request and response logs

```bash
DEBUG=true yarn es scripts/test.ts 
```

Output example

````shell
GET https://cat-fact.herokuapp.com/facts
{
  time: 'NaNms',
  init: 'https://cat-fact.herokuapp.com/facts',
  options: { headers: { 'user-agent': 'node-fetch' } },
  json: [
    {
      status: { verified: true, feedback: '', sentCount: 1 },
      _id: '5887e1d85c873e0011036889',
      user: '5a9ac18c7478810ea6c06381',
      text: 'Cats make about 100 different sounds. Dogs make only about 10.',
      __v: 0,
      source: 'user',
      updatedAt: '2020-09-03T16:39:39.578Z',
      type: 'cat',
      createdAt: '2018-01-15T21:20:00.003Z',
      deleted: false,
      used: true
    },    
  ],
  ok: true,
  status: 200,
  curl: `curl 'https://cat-fact.herokuapp.com/facts' -H "user-agent: node-fetch"`
}
````

Save request to mock

```bash
WRITE_MOCK=true DEBUG=true yarn es scripts/test.ts 
```

Go check `mock-requests.json`

Reply requests from mock

```bash
USE_MOCK=true DEBUG=true yarn es scripts/test.ts
```
npm package: @nohns/algebra.js
Description: Build, display, and solve algebraic equations.
Author: Nicole White
Latest version: 0.2.9

# algebra.js 

[![Build Status](https://travis-ci.org/nicolewhite/algebra.js.svg?branch=master)](https://travis-ci.org/nicolewhite/algebra.js)
[![Coverage Status](https://coveralls.io/repos/nicolewhite/algebra.js/badge.svg?branch=master)](https://coveralls.io/r/nicolewhite/algebra.js?branch=master)
[![npm version](https://badge.fury.io/js/algebra.js.svg)](http://badge.fury.io/js/algebra.js)
[![Join the chat at https://gitter.im/nicolewhite/algebra.js](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/nicolewhite/algebra.js?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Quick Start

```js
var expr = new Expression("x");
expr = expr.subtract(3);
expr = expr.add("x");

console.log(expr.toString());
```

```
2x - 3
```

```js
var eq = new Equation(expr, 4);

console.log(eq.toString());
```

```
2x - 3 = 4
```

```js
var x = eq.solveFor("x");

console.log("x = " + x.toString());
```

```
x = 7/2
```

[Read the full documentation at the project site](http://algebra.js.org).

## Install

### Stable Release

#### In Node

```
npm install algebra.js
```

#### In the Browser

Download [algebra.min.js](http://algebra.js.org/javascripts/algebra-0.2.6.min.js).

### Latest Development Release

```
git clone https://github.com/nicolewhite/algebra.js.git
cd algebra.js
```

#### In Node

```js
var algebra = require("./algebra");
```

#### In the Browser

The following will build `algebra.js` in the `build` directory.

```
make bundle
```

The following will build `algebra.min.js` in the `build` directory.

```
make minify
```
npm package: @noho-digital/remix-icons-svg
Description: All ~3200 [Remix Icons](https://remixicon.com/) as importable SVG strings with framework wrapper components for Svelte, React, and Vue.
Latest version: 1.0.1

# @noho-digital/remix-icons-svg

All ~3200 [Remix Icons](https://remixicon.com/) as importable SVG strings with framework wrapper components for Svelte, React, and Vue.

## Install

```bash
npm install @noho-digital/remix-icons-svg
```

## Usage

### SVG Strings (framework-agnostic)

```js
import { RiHomeLine, RiSearchFill } from '@noho-digital/remix-icons-svg';
// Each export is an SVG string: '<svg viewBox="0 0 24 24" ...>...</svg>'
```

### Svelte

```svelte
<script>
  import { RiHomeLine, RiSearchFill } from '@noho-digital/remix-icons-svg';
  import { Icon } from '@noho-digital/remix-icons-svg/svelte';
</script>

<Icon icon={RiHomeLine} size="md" alt="Home" />
<Icon icon={RiSearchFill} size="sm" />
```

### React

```jsx
import { RiHomeLine, RiSearchFill } from '@noho-digital/remix-icons-svg';
import { Icon } from '@noho-digital/remix-icons-svg/react';

function App() {
  return (
    <>
      <Icon icon={RiHomeLine} size="md" alt="Home" />
      <Icon icon={RiSearchFill} size="sm" />
    </>
  );
}
```

### Vue / Nuxt

```vue
<script setup>
import { RiHomeLine, RiSearchFill } from '@noho-digital/remix-icons-svg';
import { Icon } from '@noho-digital/remix-icons-svg/vue';
</script>

<template>
  <Icon :icon="RiHomeLine" size="md" alt="Home" />
  <Icon :icon="RiSearchFill" size="sm" />
</template>
```

### Direct SVG file import

```js
import icon from '@noho-digital/remix-icons-svg/icons/RiHomeLine.svg';
```

## Icon Component Props

| Prop | Type | Default | Description |
|------|------|---------|-------------|
| `icon` | `string` | required | SVG string from this package |
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | `'sm'` | Icon size |
| `alt` | `string` | `''` | Accessible label (sets `role="img"`) |
| `class` / `className` | `string` | `''` | Additional CSS classes (React uses `className`) |

### Sizes

| Size | Dimensions |
|------|-----------|
| `xs` | 12px (0.75rem) |
| `sm` | 16px (1rem) |
| `md` | 20px (1.25rem) |
| `lg` | 24px (1.5rem) |

## Icon Naming

Icons follow PascalCase with an `Ri` prefix:
- `home-line.svg` → `RiHomeLine`
- `search-fill.svg` → `RiSearchFill`

## How It Works

The icon components use CSS `mask-image` to render SVGs. The icon inherits `currentColor` from its parent, making it easy to style with CSS or Tailwind (`text-red-500`, etc.).

## License

Icons are from [Remix Icon](https://github.com/nicedoc/remixicon) (Apache 2.0).
npm package: @nohost/connect
Description: 处理请求转发的模块
Author: avwu
Latest version: 1.4.0
Deprecated: Use package '@nohost/router' instead

# connect
Nohost 内部处理请求转发的模块

# 安装
``` sh
npm i --save @nohost/connect
```

# 用法
``` js
const { getRawHeaders, request, tunnel, upgrade } = require('@nohost/connect');
```

# API

1. `const rawHeaders = getRawHeaders(req|res)`：还原请求或响应头大小写
2. `const svrRes = await request(req, res, options)` ：
    - options: 可选，目标服务器的 IP（域名）及端口
    - req：请求对象
    - res: 响应对象
    - svrRes: 上游服务响应对象
3. `tunnel(req, options)`：代理隧道代理
4. `upgrade(req, options)`：转发 WebSocket 请求

# 例子
参考：https://github.com/nohosts/router/blob/master/lib/connect.js
npm package: @nohost/router
Description: Nohost cluster router
Author: avwu
Latest version: 1.1.0

# router
> 以下需要使用最新版的 nohost：https://github.com/nohosts/nohost

nohost 集群部署时，用来分发请求到各个节点的路由器。

# 安装
``` sh
npm i --save @nohost/router
```

# 使用

``` js
const Router = require('@nohost/router');

const {
  SPACE_NAME,
  GROUP_NAME,
  ENV_NAME,
  NOHOST_RULE,
  NOHOST_VALUE,
  CLIENT_ID,
  CLIENT_ID_FILTER,
  writeHead,
  writeError,
} = Router;
// 初始化传人部署的 nohost 服务器列表
const router = new Router([
    {
      host: '10.11.12.13',
      port: 8080
    },
    ...
  ]);

// 更新服务器列表


// 支持http、websocket、tunnel
try {
  const svrRes = await router.proxy(req, res);
  writeHead(res, svrRes);
  svrRes.pipe(res);
} catch (err) {
  writeError(res, err);
}

// 查看抓包请求
router.proxyUI(req, res);
```

#### 更新服务器列表
``` js
router.update([
  {
    host: '10.11.12.13',
    port: 8080
  },
  {
    host: '10.31.32.33',
    port: 8080
  },
  ...
]);
```
> router 每 12s 会检测一遍所有服务，并剔除不可用的

#### 转发正常请求
``` js
const getOptions = (req) => {
  const { headers } = req;
  const spaceName = 'imweb';
  let gruopName;
  let envName;
  if (headers.host === 'km.oa2.com') {
    gruopName = 'avenwu';
    envName = '测试'; // 可选
  } else if (req.headers.host !== 'km.oa.com') {
    gruopName = 'avenwu2';
    envName = '测试2'; // 可选
  }

  return {
    rules: 'file://{test.html} km.oa2.com www.test2.com',
    values: { 'test.html': 'hell world.' },
    spaceName,
    gruopName,
    envName,
    callback: console.log, // 可选
    // clientId: 'test', // 如果从外网转发过来的带登录态请求，设置下 clientId 方便插件当前用户的请求抓包
  };
};

router.proxy(req, res, getOptions(req));

// 或自己处理响应
// const svrRes = await router.proxy(req);

```
#### 查看抓包数据
``` js
router.proxyUI(req, res, getOptions(req));
```

### 只转发到指定 Nohost 服务
``` js
const Router = require('@nohost/router');

const router = new Router({
    host: '10.x.x.x',
    port: 8080,
});

router.proxy(req, res); // 同测试用例，无需设置 space / group，env 按需设置
router.proxyUI(req, res); // 同测试用例，无需设置 space / group，env 按需设置
```

具体实现参考：[测试用例](./test/README.md)
npm package: @nohvoyagemap/voyage-svg
Description: Angular library to create custom map-based Voyages with SVGs
Author: noh voyage
Latest version: 5.0.1

# Introduction 
TODO: Give a short introduction of your project. Let this section explain the objectives or the motivation behind this project. 

# Getting Started
TODO: Guide users through getting your code up and running on their own system. In this section you can talk about:
1.	Installation process
2.	Software dependencies
3.	Latest releases
4.	API references

# Build and Test
TODO: Describe and show how to build your code and run the tests. 

# Contribute
TODO: Explain how other users and developers can contribute to make your code better. 

If you want to learn more about creating good readme files then refer the following [guidelines](https://docs.microsoft.com/en-us/azure/devops/repos/git/create-a-readme?view=azure-devops). You can also seek inspiration from the below readme files:
- [ASP.NET Core](https://github.com/aspnet/Home)
- [Visual Studio Code](https://github.com/Microsoft/vscode)
- [Chakra Core](https://github.com/Microsoft/ChakraCore)