open-index/open-npm huggingface dataset:
npm package: @kingv/cli
Description: Vant Cli 是一个 Vue 组件库构建工具，通过 Vant Cli 可以快速搭建一套功能完备的 Vue 组件库。
Author: chenjiahan
Latest version: 4.0.2

# 本 cli 是在 Vant cli 基础上修改而来
## 修改 site desktop 模板代码
# Vant Cli

Vant Cli 是一个 Vue 组件库构建工具，通过 Vant Cli 可以快速搭建一套功能完备的 Vue 组件库。

### 特性

- 提供丰富的命令，涵盖从开发测试到构建发布的完整流程
- 基于约定的目录结构，自动生成优雅的文档站点和组件示例
- 内置 ESlint、Stylelint 校验规则，提交代码时自动执行校验
- 构建后的组件库默认支持按需引入、主题定制、Tree Shaking

### 快速上手

执行以下命令可以快速创建一个基于 Vant Cli 的项目：

```bash
yarn create vant-cli-app
```

### 手动安装

```shell
# 通过 npm
npm i @vant/cli -D

# 通过 yarn
yarn add @vant/cli -D

# 通过 pnpm
pnpm add @vant/cli -D
```

安装完成后，请将以下配置添加到 package.json 文件中

```json
{
  "scripts": {
    "dev": "vant-cli dev",
    "test": "vant-cli test",
    "lint": "vant-cli lint",
    "build": "vant-cli build",
    "prepare": "husky install",
    "release": "vant-cli release",
    "build-site": "vant-cli build-site"
  },
  "lint-staged": {
    "*.md": "prettier --write",
    "*.{ts,tsx,js,vue,less,scss}": "prettier --write",
    "*.{ts,tsx,js,vue}": "eslint --fix",
    "*.{vue,css,less,scss}": "stylelint --fix"
  },
  "eslintConfig": {
    "root": true,
    "extends": ["@vant"]
  },
  "stylelint": {
    "extends": ["@vant/stylelint-config"]
  },
  "prettier": {
    "singleQuote": true
  },
  "browserslist": ["Chrome >= 51", "iOS >= 10"]
}
```

## 详细文档

- [命令](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/commands.md)
- [配置指南](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/config.md)
- [目录结构](https://github.com/youzan/vant/tree/dev/packages/vant-cli/docs/directory.md)
- [更新日志](https://github.com/youzan/vant/tree/dev/packages/vant-cli/changelog.md)
npm package: @kingworks/deploy-cli
Description: Zero-configuration CLI tool for deploying to dual-region CDN infrastructure
Latest version: 1.1.1

# @kingworks/deploy-cli

Zero-configuration CLI tool for deploying web applications to dual-region CDN infrastructure (China and Malaysia).

## Features

- Zero configuration - automatically detects project name from git
- Dual-region deployment - deploys to CN and MY regions in parallel
- Secure authentication - Feishu OAuth with automatic token refresh
- Deployment tracking - complete audit trail of all deployments
- Fast uploads - uses STS tokens and parallel uploads

## Installation

```bash
npm install -g @kingworks/deploy-cli
```

**That's it!** All dependencies (including `@zwr/one-click-upload`) are automatically installed.

No additional packages needed. 🎉

## Configuration

After installation, you need to configure the CLI:

### Quick Setup (Recommended)

```bash
# Create global configuration
mkdir -p ~/.deploy-cli
cat > ~/.deploy-cli/.env << EOF
DEPLOY_API_URL=https://your-api-url.com
FEISHU_CLIENT_ID=cli_your_id
EOF
```

### Required Configuration

- `DEPLOY_API_URL` - Your backend API URL (required)
- `FEISHU_CLIENT_ID` - Feishu OAuth Client ID (optional, defaults to `cli_xxx`)

You only need `DEPLOY_API_URL`. `FEISHU_CLIENT_ID` is optional.

## Usage

### First-time setup

```bash
# Login with Feishu
deploy login
```

### Deploy to environments

```bash
# Deploy to test environment
deploy test

# Deploy to pre-release environment
deploy pre

# Deploy to production environment
deploy prod
```

### Logout

```bash
deploy logout
```

## Requirements

- Node.js 18 or higher
- Git repository
- Built application in `./dist/` directory
- Feishu account with deployment permissions

## How it works

1. Detects project name from git repository
2. Validates authentication token (auto-refreshes if needed)
3. Requests STS tokens from backend for both CN and MY regions
4. Uploads files to both regions in parallel
5. Reports deployment results to backend
6. Displays CDN URLs for both regions

## Environment Variables

- `DEPLOY_ENV`: Set to `local` for local development (default: production)

## License

MIT

## Documentation

Run `deploy --help` to view the full Chinese command help.
npm package: @kingworldjs/bearer
Description: A plugin for kingworld for retreiving Bearer token
Author: saltyAom
Latest version: 0.0.0-experimental.1

# @kingworldjs/bearer
A plugin for [kingworld](https://github.com/saltyaom/kingworld) for retreiving Bearer token.

This plugin is for retrieving a Bearer token specified in [RFC6750](https://www.rfc-editor.org/rfc/rfc6750#section-2).

This plugin **DOES NOT** handle authentication validation for your server, rather the plugin leaves the decision for developers to apply logic for handle validation check themself.

## Installation
```bash
bun add @kingworldjs/bearer
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { bearer } from '@kingworldjs/bearer'

const app = new KingWorld()
    .use(bearer())
    .get('/sign', ({ bearer }) => bearer, {
        beforeHandle({ bearer, set }) {
            if (!bearer) {
                set.status = 400
                set.headers[
                    'WWW-Authenticate'
                ] = `Bearer realm='sign', error="invalid_request"`

                return 'Unauthorized'
            }
        }
    })
    .listen(8080)
```

## API
This plugin decorates `bearer` into `Context`.

### bearer
Extracted bearer token according to RFC6750, is either `string` or `undefined`,

If is undefined, means that there's no token provided.

## Config
Below is the configurable property for customizing the Bearer plugin.

### Extract
Custom extractor for retrieving tokens when the API doesn't compliant with RFC6750.

```typescript
/**
 * If the API doesn't compliant with RFC6750
 * The key for extracting the token is configurable
 */
extract: {
    /**
     * Determined which fields to be identified as Bearer token
     *
     * @default access_token
     */
    body?: string
    /**
     * Determined which fields to be identified as Bearer token
     *
     * @default access_token
     */
    query?: string
    /**
     * Determined which type of Authentication should be Bearer token
     *
     * @default Bearer
     */
    header?: string
}
```
npm package: @kingworldjs/cors
Description: A plugin for kingworld that for Cross Origin Requests (CORs)
Author: saltyAom
Latest version: 0.0.0-experimental.4

# @kingworldjs/cors
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that for Cross Origin Requests (CORs)

## Installation
```bash
bun add @kingworldjs/cors
```

## Example
```typescript
import KingWorld from 'kingworld'
import cors from '@kingworldjs/cors'

const app = new KingWorld()
    .use(cors)
    .listen(8080)
```

## Config
### origin
@default `true`

Assign the **Access-Control-Allow-Origin** header.

Value can be one of the following:
- `string` - String of origin which will be directly assign to `Access-Control-Allow-Origin`

- `boolean` - If set to true, `Access-Control-Allow-Origin` will be set to `*` (accept all origin)

- `RegExp` - Pattern to use to test with request's url, will accept origin if matched.

- `Function` - Custom logic to validate origin acceptance or not. will accept origin if `true` is returned.
    - Function will accepts `Context` just like `Handler`
    ```typescript
    // Example usage
    app.use(cors, {
        origin: ({ request, headers }) => true
    })

    // Type Definition
    type CORSOriginFn = (context: Context) => boolean | void
    ```

- `Array<string | RegExp | Function>` - Will try to find truthy value of all options above. Will accept request if one is `true`.

### methods
@default `*`

Assign **Access-Control-Allow-Methods** header. 

Value can be one of the following:
Accept:
- `undefined | null | ''` - Ignore all methods.

- `*` - Accept all methods.

- `HTTPMethod` - Will be directly set to **Access-Control-Allow-Methods**.
    - Expects either a single method or a comma-delimited string (eg: 'GET, PUT, POST')

- `HTTPMethod[]` - Allow multiple HTTP methods.
    - eg: ['GET', 'PUT', 'POST']

### allowedHeaders
@default `*`

Assign **Access-Control-Allow-Headers** header. 

Allow incoming request with the specified headers.

Value can be one of the following:
- `string`
    - Expects either a single method or a comma-delimited string (eg: 'Content-Type, Authorization').

- `string[]` - Allow multiple HTTP methods.
    - eg: ['Content-Type', 'Authorization']

### exposedHeaders
@default `*`

Assign **Access-Control-Exposed-Headers** header. 

Return the specified headers to request in CORS mode.

Value can be one of the following:
- `string`
    - Expects either a single method or a comma-delimited string (eg: 'Content-Type, 'X-Powered-By').

- `string[]` - Allow multiple HTTP methods.
    - eg: ['Content-Type', 'X-Powered-By']

### credentials
@default `true`

Assign **Access-Control-Allow-Credentials** header. 

Allow incoming requests to send `credentials` header.

- `boolean` - Available if set to `true`.

### maxAge
@default `5`

Assign **Access-Control-Max-Age** header. 

Allow incoming requests to send `credentials` header.

- `number` - Duration in seconds to indicates how long the results of a preflight request can be cached.

### preflight
@default `true`

Add `[OPTIONS] /*` handler to handle preflight request which response with `HTTP 204` and CORS hints.

- `boolean` - Available if set to `true`.
npm package: @kingworldjs/cron
Description: A plugin for kingworld that add support for running cronjob
Author: saltyAom
Latest version: 0.0.0-experimental.1

# @kingworldjs/cron
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that add support for running cronjob.

## Installation
```bash
bun add @kingworldjs/cron
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import '@kingworldjs/cron'

const app = new KingWorld()
    .cron({
        name: 'heartbeat',
        pattern: '*/1 * * * * *'
    }, () => {
        console.log("Heartbeat")
    })
    .get('/stop', ({ store: { cron: { heartbeat } } }) => {
        heartbeat.stop()

        return 'Stop heartbeat'
    })
    .listen(8080)
```

## API
This plugin extends `cron` method to KingWorld using [cronner](https://github.com/hexagon/croner)

For documentation, `app.cron` use the same syntax as [cronner](https://github.com/hexagon/croner), so please refers to [cronner documentation](https://github.com/hexagon/croner)
npm package: @kingworldjs/graphql-jit
Description: A plugin for kingworld that add support for graphql jit
Author: saltyAom
Latest version: 0.0.0-experimental.0

# @kingworldjs/graphql-jit
An **experimental** plugin for [kingworld](https://github.com/saltyaom/kingworld) that adds support for using GraphQL JIT.

## Installation
```bash
bun add graphql @kingworldjs/graphql-jit
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { graphql } from '../src'

const app = new KingWorld()
    .get('/', () => 'Hi')
    .post('/mirror', (context) => context.body)
    .use(graphql, {
        resolvers: {
            Query: {
                hello: () => 'Hello world!'
            }
        },
        schema: `
            type Query {
                hello: String
            }`
    })
    .listen(8080)
```

### path
@default "/graphql"

Path to expose as GraphQL handler

### schema

GraphQL schema
### resolvers
Resolvers funcitons
```typescript
resolvers: {
    Query?: Record<string, Function | Promise<Function>>
    Mutation?: Record<string, Function | Promise<Function>>
    Subscription?: Record<string, Function | Promise<Function>>
}
```
npm package: @kingworldjs/graphql-yoga
Description: A plugin for kingworld for using graphql-yoga
Author: saltyAom
Latest version: 0.0.0-experimental.1

# @kingworldjs/graphql-yoga
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that add support for returning html.

## Installation
```bash
bun add graphql graphql-yoga@three @kingworldjs/graphql-yoga
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { yoga } from '@kingworldjs/graphql-yoga'

import { createYoga, createSchema } from 'graphql-yoga'

const app = new KingWorld()
    .use(
        yoga({
            path: "/graphql",
            yoga: createYoga({
                schema: createSchema({
                    typeDefs: `
                        type Query {
                            hi: String
                        }
                `,
                resolvers: {
                    Query: {
                        hi: () => 'Hi from KingWorld'
                    }
                }
            })
        })
    )
    .listen(8080)
```
### path
@default "/graphql"

Path to expose as GraphQL handler

### yoga
GraphQL Yoga instance
npm package: @kingworldjs/html
Description: A plugin for kingworld that add support for returning html
Author: saltyAom
Latest version: 0.0.0-experimental.0

# @kingworldjs/html
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that add support for returning html.

## Installation
```bash
bun add @kingworldjs/html
```

## Example
```typescript
import KingWorld from 'kingworld'
import html from '@kingworldjs/html'

const page = `<!DOCTYPE HTML>
<html lang="en">
    <head>
        <title>Hello World</title>
    </head>
    <body>
        <h1>Hello World</h1>
    </body>
</html>`

const app = new KingWorld()
    .use(html)
    .get('/', () => page)
    .get('/html', ({ html }) => html(page))
    .listen(8080)
```

## API
This plugin detect html string and add `html` method to `Context`.

If your response is start with `<!DOCTYPE` (case in-sensitive), `Content-Type` will be set to `text/html`.

Or if you want to manually return html, simply use newly added `html` function like this:
```typescript
app.get('/html', ({ html }) => html(page))
```
npm package: @kingworldjs/jwt
Description: Plugin for kingworld for using JWT Authentication
Author: saltyAom
Latest version: 0.0.0-experimental.0

# @kingworldjs/static
Plugin for [kingworld](https://github.com/saltyaom/kingworld) for using JWT Authentication.

## Installation
```bash
bun add @kingworldjs/jwt
```

## Example
```typescript
import { KingWorld, t } from 'kingworld'
import { jwt } from '@kingworldjs/jwt'
import { cookie } from '@kingworldjs/cookie'

const app = new KingWorld()
    .use(
        jwt({
            name: 'jwt',
            // This should be Environment Variable
            secret: 'MY_SECRETS'
        })
    )
    .use(cookie)
    .get('/sign/:name', async ({ jwt, cookie, setCookie, params }) => {
        setCookie('auth', await jwt.sign(params))

        return `Sign in as ${params.name}`
    })
    .get('/profile', async ({ jwt, set, cookie: { auth } }) => {
        const profile = await jwt.verify(auth)

        if (!profile) {
            set.status = 401
            return 'Unauthorized'
        }

        return `Hello ${profile.name}`
    })
    .listen(8080)

```

## Config
This package extends [jose](https://github.com/panva/jose), most config is inherited from Jose. 

Below are configurable properties for using JWT plugin

### name
Name to decorate method as:

For example, `jwt` will decorate Context with `Context.jwt`

### secret
JWT secret key

### schema
Type strict validation for JWT payload

## Jose's config
Below is the config inherits from [jose](https://github.com/panva/jose)

### alg
@default 'HS256'

Algorithm to sign JWT with

### crit
Critical Header Parameter.

### iss
JWT Issuer

@see [RFC7519#section-4.1.1](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.1)

### sub
JWT Subject

@see [RFC7519#section-4.1.2](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.2)

### aud
JWT Audience 

@see [RFC7519#section-4.1.3](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.3)

### jti
JWT ID

@see [RFC7519#section-4.1.7](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.7)

### nbf
JWT Not Before

@see [RFC7519#section-4.1.5](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.5)

### exp
JWT Expiration Time

@see [RFC7519#section-4.1.4](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4)

### iat
JWT Issued At

@see [RFC7519#section-4.1.6](https://www.rfc-editor.org/rfc/rfc7519#section-4.1.6)
npm package: @kingworldjs/schema
Description: Plugin for declaratively validation of incoming request
Author: saltyAom
Latest version: 0.0.0-experimental.4

# @kingworldjs/schema
Plugin for [kingworld](https://github.com/saltyaom/kingworld) for declaratively validation of incoming request.

## Installation
```bash
bun add @kingworldjs/schema
```

## Schema Validation
Use [@kingworldjs/schema](https://github.com/saltyaom/kingworld-schema) handle typed-strict validation of incoming request.

Schema validation is capable of validation of:
- body
- header
- query
- params

And optional config:
- customError `(type: SchemaType, error: Error | TypeError) => any`
    - Return custom error message response

Schema plugin use [fastest-validator](https://github.com/icebob/fastest-validator) for schema validation and declaration which has full TypeScript supports and auto-complete.

#### Example
```typescript
import KingWorld from 'kingworld'
import schema from '@kingworldjs/schema'

new KingWorld()
    .get<{
        params: {
            id: number
        }
    }>('/id/:id', ({ request: { params: { id } } }) => id, {
        transform: (request, store) {
            request.params.id = +request.params.id
        },
        preHandler: schema({
            params: {
                id: {
                    type: "number",
                    min: 1,
                    max: 100
                }
            }
        })
    })
    .listen(3000)

// [GET] /id/2 => 2
// [GET] /id/500 => Invalid params
// [GET] /id/-3 => Invalid params
```

To use validation on group scope, simply attach `schema` to `preHandler`:
```typescript
import KingWorld from 'kingworld'
import schema from '@kingworldjs/schema'

new KingWorld()
    .group('/group', (app) => app
        .preHandler(schema({
            params: {
                id: {
                    type: "number",
                    min: 1,
                    max: 100
                }
            }
        }))
        .get<{
            params: {
                id: number
            }
        }>('/user/:id', ({ request: { params: { id } } }) => id, {
            transform: (request, store) {
                request.params.id = +request.params.id
            }
        })
        .get<{
            params: {
                id: number
            }
        }>('/post/:id', ({ request: { params: { id } } }) => id, {
            transform: (request, store) {
                request.params.id = +request.params.id
            }
        })
    )
    .listen(3000)

// [GET] /user/2 => 2
// [GET] /user/500 => Invalid params
// [GET] /post/-3 => Invalid params
```

## Gotcha
Schema validation will be handle in order of `preHandler`.
To make sure everything is expected, please place schema plugin before any other preHandler that might depends on schema plugin.
npm package: @kingworldjs/static
Description: Plugin for kingworld for serving static folder.
Author: saltyAom
Latest version: 0.0.0-experimental.2

# @kingworldjs/static
Plugin for [kingworld](https://github.com/saltyaom/kingworld) for serving static folder.

## Installation
```bash
bun add @kingworldjs/static
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { staticPlugin } from '@kingworldjs/static'

const app = new KingWorld()
    .use(staticPlugin)
    .listen(8080)
```

## Config
Below is an available config for a static plugin.

### path
@default "public"

Path to expose as a public path

### prefix
@default '/public'

Path prefix to create a virtual mount path for the static directory

### staticLimit
@defualt 1024

If total files exceed this number, the file will be handled via wildcard instead of the static route to reduce memory usage

### alwaysStatic
@default boolean

If set to true, the file will always use a static path instead
npm package: @kingworldjs/swagger
Description: A plugin for kingworld to auto-generate Swagger page
Author: saltyAom
Latest version: 0.0.0-experimental.3

# @kingworldjs/swagger
A plugin for [kingworld](https://github.com/saltyaom/kingworld) to auto-generate Swagger page.

## Installation
```bash
bun add @kingworldjs/swagger
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { swagger } from '@kingworldjs/swagger'

const app = new KingWorld()
    .use(swagger())
    .get('/', () => 'hi')
    .get('/unpath/:id', ({ params: { id } }) => id)
    .get('/unpath/:id/:name', ({ params: { id, name } }) => `${id} ${name}`)
    .post(
        '/json/:id',
        ({ body, params: { id }, query: { name } }) => ({
            ...body,
            id,
            name
        }),
        {
            schema: {
                params: t.Object({
                    id: t.String()
                }),
                query: t.Object({
                    name: t.String()
                }),
                body: t.Object({
                    username: t.String(),
                    password: t.String()
                }),
                response: t.Object({
                    username: t.String(),
                    password: t.String(),
                    id: t.String(),
                    name: t.String()
                })
            }
        }
    )
    .listen(8080)
```

Then go to `http://localhost:8080/swagger`.

# config

## swagger
Customize Swagger config, refers to [Swagger 2.0 config](https://swagger.io/specification/v2/)

## path
@default '/swagger'

The endpoint to expose Swagger

## excludeStaticFile
@default true

Determine if Swagger should exclude static files.

## exclude
@default []

Paths to exclude from the Swagger endpoint
npm package: @kingworldjs/trpc
Description: A plugin for kingworld that add support for using tRPC
Author: saltyAom
Latest version: 0.0.0-experimental.1

# @kingworldjs/trpc
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that add support for using tRPC.

## Installation
```bash
bun add @kingworldjs/trpc
```

## Example
```typescript
import { KingWorld, t } from 'kingworld'
import { compile as c } from '@kingworldjs/trpc'

import { initTRPC } from '@trpc/server'

const r = initTRPC.create()

const router = r.router({
    greet: r.procedure.input(c(t.String())).query(({ input }) => input)
})

export type Router = typeof router

const app = new KingWorld()
    .trpc(router)
    .listen(8080)
```

## API
This plugin extends the new method `trpc` to `KingWorld` class.

### trpc
Register tRPC router.

```typescript
type tRPC = (router: Router<any>, options?: TRPCOptions) => this

export interface TRPCOptions
    extends Omit<
        FetchHandlerRequestOptions<any>,
        'req' | 'router' | 'endpoint'
    > {
    /**
     * tRPC endpoint
     *
     * @default '/trpc'
     */
    endpoint?: string
}
```

## Note
WebSocket API is in an experimental state and unstable. 

Is meant for experimental for better stabilization.
npm package: @kingworldjs/websocket
Description: A plugin for kingworld that add support for websocket
Author: saltyAom
Latest version: 0.0.0-experimental.7

# @kingworldjs/websocket
A plugin for [kingworld](https://github.com/saltyaom/kingworld) that add support for websocket.

## Installation
```bash
bun add @kingworldjs/websocket
```

## Example
```typescript
import { KingWorld } from 'kingworld'
import { websocket } from '@kingworldjs/websocket'

const app = new KingWorld()
    .use(websocket())
    .ws('/ws', {
        message(ws, message) {
            ws.message('Hi')
        }
    })
    .listen(8080)
```

## API
This plugin extends `KingWorld` class with `ws` method.

## ws
Register Websocket to route

Parameters:
```typescript
ws(
    path: string,
    options: Partial<WebSocketHandler<Context>> & {
        schema?: Schema
        beforeHandle?: WithArray<HookHandler>
        headers?:
            | HeadersInit
            | (Context) => HeadersInt
    }
): this
```