open-index/open-npm huggingface dataset:
npm package: @midway3-components/cli
Description: 在 CLI 场景下运行 Midway 框架。 Web 是 [`Midway`](https://github.com/midwayjs/midway) 框架的主要目标场景，官方似乎并没有为命令行环境提供相应的组件（Framework）。 一个趁手的命令行工具无论对于调试还是后台管理都是非常必要的，所以就有了这个组件。 命令解析工作由 [`yargs`](https://github.com/yargs/yargs) 完成。
Author: Billy Poon
Latest version: 0.1.16

# @midway3-components/cli

在 CLI 场景下运行 Midway 框架。
Web 是 [`Midway`](https://github.com/midwayjs/midway) 框架的主要目标场景，官方似乎并没有为命令行环境提供相应的组件（Framework）。
一个趁手的命令行工具无论对于调试还是后台管理都是非常必要的，所以就有了这个组件。
命令解析工作由 [`yargs`](https://github.com/yargs/yargs) 完成。

> 注意，`@midway3-components/cli` 的目标是在 CLI 场景下运行业务逻辑，并不是对 `@midwayjs/cli` 的替代，两者几乎毫无关联。

## Demo
See [`@midway-components/demo`](https://github.com/billy-poon/midway3-components/tree/main/packages/demo) for full example.
npm package: @midway3-components/core
Description: Make JSON serializing easier for [`Midway.js`](https://www.midwayjs.org/).
Author: Billy Poon
Latest version: 0.1.13

# @midway3-components/core

Make JSON serializing easier for [`Midway.js`](https://www.midwayjs.org/).

## Demo
See [`@midway-components/demo`](https://github.com/billy-poon/midway3-components/tree/main/packages/demo) for full example.
npm package: @midway3-components/drizzle
Description: [`drizzle`](https://orm.drizzle.team/) component for [`Midway.js`](https://www.midwayjs.org/).
Author: Billy Poon
Latest version: 0.1.18

# @midway3-components/drizzle

[`drizzle`](https://orm.drizzle.team/) component for [`Midway.js`](https://www.midwayjs.org/).

## Demo
See [`@midway-components/demo`](https://github.com/billy-poon/midway3-components/tree/main/packages/demo) for full example.
npm package: @midway3-components/web
Description: Some util codes for [`Midway.js`](https://www.midwayjs.org/).
Author: Billy Poon
Latest version: 0.1.14

# @midway3-components/web

Some util codes for [`Midway.js`](https://www.midwayjs.org/).

## Demo
See [`@midway-components/demo`](https://github.com/billy-poon/midway3-components/tree/main/packages/demo) for full example.
npm package: @midwayjs-component/egg
Latest version: 1.0.8

# midway component for egg


## Install

```bash
npm i @midwayjs-component/egg --save
```

## Usage

add egg plugin in `plugin.ts` or other env.

```js
// plugin.ts
export default {
  mysql: {
    enable: true,
    package: 'egg-mysql'
  }
},
```

```js
// config.default.ts
{
  mysql: {
    //... other config for mysql plugin
  }
}
```

In Code, you can use plugin like midway.

```ts

export class IndexHandler implements FunctionHandler {
  @Inject()
  ctx: FaaSContext;

  @Plugin()
  mysql;

  @Func('index.handler')
  async handler() {
    // this.mysql.xxxx
    // or this.ctx.xxxx
  }
}

```


## Some differences

- No agent worker and IPC Messager
- Does not support stream related plugins
- Will not load the current directory as a plugin
npm package: @midwayjs-examples/eggjs-migrate-serverless
Description: midway serverless + eggjs 迁移方案
Latest version: 1.0.1

# Midway Serverless with eggjs migration

midway serverless + eggjs 迁移方案

本示例是通过 egg-init 生成，加上迁移的 `f.yml` 而成。
npm package: @midwayjs-examples/faas-with-covid19
Description: midway faas + react + covid19 data
Latest version: 1.0.4

# Midway Serverless with react-covid19

midway faas + react + covid19 data

![](https://gw.alicdn.com/tfs/TB1JMxfHFT7gK0jSZFpXXaTkpXa-1917-965.png)
npm package: @midwayjs-examples/faas-with-mysql
Description: midway faas + mysql 一体化开发脚手架
Latest version: 1.0.1

# midway faas with mysql

midway faas + mysql 一体化开发脚手架

![](https://gw.alicdn.com/tfs/TB1owaLaepyVu4jSZFhXXbBpVXa-1266-1232.png)
npm package: @midwayjs-examples/faas-with-ots
Description: midway faas + ots 一体化开发脚手架
Latest version: 1.0.4

# Midway Serverless with ots

midway faas + ots 一体化开发脚手架

![](https://gw.alicdn.com/tfs/TB1owaLaepyVu4jSZFhXXbBpVXa-1266-1232.png)
npm package: @midwayjs-examples/faas-with-rds
Description: midway faas + mysql 一体化开发脚手架
Latest version: 1.0.3

# Midway Serverless with mysql

midway faas + mysql 一体化开发脚手架

![](https://gw.alicdn.com/tfs/TB1owaLaepyVu4jSZFhXXbBpVXa-1266-1232.png)
npm package: @midwayjs-examples/faas-with-react
Description: midway serverless + react 一体化开发脚手架
Latest version: 1.0.9

# Midway Serverless with react

midway serverless + react 一体化开发脚手架

![](https://cdn.nlark.com/yuque/0/2020/png/501408/1589451091958-2c8a1034-4b93-4f85-af96-92353e8a712a.png?x-oss-process=image%2Fresize%2Cw_746)
npm package: @midwayjs-examples/faas-with-vue
Description: midway faas + vue 一体化开发脚手架
Latest version: 1.0.11

# Midway Serverless with vue

midway faas + vue 一体化开发脚手架

![](https://cdn.nlark.com/yuque/0/2020/png/501408/1589450022212-668b9955-7ea7-47cf-ab5d-a75c4709f9b0.png?x-oss-process=image%2Fresize%2Cw_746)
npm package: @midwayjs-examples/midway-hooks-react
Description: Midway Serverless hooks + React 一体化开发脚手架
Latest version: 1.0.10

# Midway Serverless with React

Midway Serverless hooks + React 一体化开发脚手架

![](https://gw.alicdn.com/tfs/TB1B9phR.z1gK0jSZLeXXb9kVXa-2880-1800.png)
npm package: @midwayjs-examples/midway-hooks-vue3
Description: Midway Serverless hooks + Vue3 一体化开发脚手架
Latest version: 1.0.4

# Midway Serverless with Vue3

Midway Serverless hooks + Vue3 一体化开发脚手架

![](https://gw.alicdn.com/tfs/TB1B9phR.z1gK0jSZLeXXb9kVXa-2880-1800.png)
npm package: @midwayjs-plus/bull-board
Description: midway component for bull
Latest version: 3.9.0

# @midwayjs/bull-board

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs-plus/otel
Description: midway open telemetry component
Latest version: 3.10.2

# midwayjs open-telemetry module

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.


## Install

```bash
$ npm install --save @opentelemetry/api
$ npm install --save @opentelemetry/sdk-node
$ npm install --save @opentelemetry/auto-instrumentations-node
```

Install component if you want decorator support.

```bash
$ npm i @midwayjs/otel@3 --save
```

## Enable open-telemetry

open-telemetry must be loaded at the first of user code.

you can add at `bootstrap.js`.

```typescript
const process = require('process');
const opentelemetry = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { ConsoleSpanExporter } = require('@opentelemetry/sdk-trace-base');
const { Resource } = require('@opentelemetry/resources');
const { SemanticResourceAttributes } = require('@opentelemetry/semantic-conventions');
const { Bootstrap } = require('@midwayjs/bootstrap');

// configure the SDK to export telemetry data to the console
// enable all auto-instrumentations from the meta package
const traceExporter = new ConsoleSpanExporter();
const sdk = new opentelemetry.NodeSDK({
  resource: new Resource({
    [SemanticResourceAttributes.SERVICE_NAME]: 'my-service',
  }),
  traceExporter,
  instrumentations: [getNodeAutoInstrumentations()]
});

// initialize the SDK and register with the OpenTelemetry API
// this enables the API to record telemetry
sdk.start()
  .then(() => {
    return Bootstrap
      .configure(/**/)
      .run();
  });

// gracefully shut down the SDK on process exit
process.on('SIGTERM', () => {
  sdk.shutdown()
    .then(() => console.log('Tracing terminated'))
    .catch((error) => console.log('Error terminating tracing', error))
    .finally(() => process.exit(0));
});
```

You can find more information at [opentelemetry-js](https://github.com/open-telemetry/opentelemetry-js)


## Decorator Support

Enable component first.

```typescript
import { Configuration } from '@midwayjs/decorator';
import * as koa from '@midwayjs/koa';
import * as otel from '@midwayjs/otel';

@Configuration({
  imports: [
    koa,
    otel
  ]
})
export class MainConfiguration {
}
```

Otel component add a @Trace decorator for method.

```typescript
export class UserService {

  @Trace('user.get')
  async getUser() {
    // ...
  }
}
```

it will create a new span in current trace.


## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs-plus/redis
Description: an extention of midway redis component
Latest version: 3.9.4

# midwayjs redis module

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs-plus/sequelize
Description: this is a sub package for midway.
Latest version: 3.9.1

# midway sequelize component

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs-plus/storage
Description: midway plus storage component
Latest version: 3.10.4

# midwayjs aws-s3 module

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT](<(http://github.com/midwayjs/midway/blob/master/LICENSE)>)
npm package: @midwayjs-plus/throttler
Description: midway throttler base on traffic-throttler
Latest version: 3.9.3

## midway-throttler

midway request throttler component, based on [traffic-throttler](https://www.npmjs.com/package/traffic-throttler)。 It's core design base on [@nestjs/throttler](https://www.npmjs.com/package/@nestjs/throttler), and API will same as [@nestjs/throttler](https://www.npmjs.com/package/@nestjs/throttler).

这是基于 midway 3.0 的限流器组件模块，基于 [traffic-throttler](https://www.npmjs.com/package/traffic-throttler) 封装。核心逻辑来自 [@nestjs/throttler](https://www.npmjs.com/package/@nestjs/throttler), API 用法也尽量与其保持一致


## Install （安装）

> npm i midway-throttler --save

## Usage（用法）

### 1. 引入组件

首先在 src/configuration.ts 中引入组件，并且配置[全局守卫](https://midwayjs.org/docs/guard#%E5%85%A8%E5%B1%80%E5%AE%88%E5%8D%AB)

```typescript
import * as throttler from 'midway-throttler';
import { ThrottlerGuard } from 'midway-throttler';
import * as koa from '@midwayjs/koa';

@Configuration({
  imports: [koa, throttler], //import throttler 组件
  importConfigs: [join(__dirname, './config')],
})
export class ContainerLifeCycle {
  @App()
  app: koa.Application;

  async onReady() {
    //全局守卫配置
    this.app.useGuard(ThrottlerGuard);
  }
}
```

### 2. 配置相关参数

在 config.default.ts 配置文件中，配置如下

```typescript
throttler: {
  ttl?: number,    //时间窗口，在该时间段内限制 limit 个数的请求， 超出限流
  limit?: number,   //请求个数限制
  storage?: IThrottlerStorageOption,    //内部存储配置，支持 memory | redis 两种存储方式
  errorMsg?: string,  //超出限流后的报错信息
}
```

针对某些 Controller 或者某些 Method, 支持

1. 想覆盖全局配置，可以通过 Throttle 装饰器进行配置修改;
2. 想要不限流，可以通过 SkipThrottle 装饰器放开限流

```typescript
import { Controller, Get } from '@midwayjs/decorator';
import { SkipThrottle, Throttle } from 'midway-throttler';

@Throttle(2, 20) //重新配置
@Controller('/')
export class HomeController {
  @Throttle(1, 10) //重新配置
  @Get('/')
  async home(): Promise<string> {
    return 'Hello Midwayjs!';
  }

  @SkipThrottle(true) //该请求不限流
  @Get('/skip')
  async doSkip(): Promise<string> {
    return 'I am skip, no throttle';
  }
}
```

## Example（例子）

1. cd example
2. npm i
3. npm run dev
npm package: @midwayjs/async-hooks-context-manager
Description: midway async hooks context manager
Author: Harry Chen
Latest version: 3.20.23

# midway-async-hooks-context-manager

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/axios
Description: midway http client with axios
Author: czy88840616
Latest version: 3.20.23

# midway axios component

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/bootstrap
Description: midwayjs bootstrap
Author: Harry Chen
Latest version: 3.20.23

# midway-bootstrap

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/bootstrap.svg)](http://packagequality.com/#?package=@midwayjs/bootstrap)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/bull-board
Description: midway component for bull-board
Latest version: 3.20.23

# @midwayjs/bull-board

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/bullmq
Description: midway component for BullMQ
Author: guo qicong
Latest version: 3.20.23

# @midwayjs/bullmq

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/busboy
Description: Midway Component for upload
Latest version: 3.20.23

# midway busboy module

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/validate.svg)](http://packagequality.com/#?package=@midwayjs/busboy)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cache
Description: midway cache manager
Latest version: 3.14.0

# midway-cache

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cache-manager
Description: midway cache manager
Latest version: 3.20.23

# midway cache manager

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cache-manager-redis
Description: midway redis store for cache manager
Latest version: 3.14.0

# midway cache manager redis store

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/captcha
Description: Midway Component for Captcha(Verification Code)
Latest version: 3.20.23

# midway captcha(verification code) module

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/casbin
Description: midway casbin component
Author: czy88840616
Latest version: 3.20.23

# midwayjs casbin module

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/casbin-redis-adapter
Description: midway casbin redis adapter
Author: czy88840616
Latest version: 3.20.23

# midwayjs casbin with redis

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/casbin-typeorm-adapter
Description: midway casbin typeorm adapter
Author: czy88840616
Latest version: 3.20.23

# midwayjs casbin with typeorm

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/code-dye
Description: Midway Code Dye Component
Latest version: 3.20.23

# midway-codedye

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/code-operation
Description: code-operation
Author: echosoar
Latest version: 0.1.0

## Midway Code Operation

代码操作工具，便捷修改 midway serverless项目的 config / configuration

## Usage

### config
```typescript
const izr = new MidwayInitializr({
  root,
});
izr.config({
  b: {
    local: 123,
    pre: 345
  },
});
izr.output();
```

### configuration
```typescript
const izr = new MidwayInitializr({
  root,
});
izr.configuration({
  deps: {
    '@midwayjs/decorator': {
      nameList: ['Inject', 'Config', 'Logger'],
    },
  },
  decoratorParams: {
    importConfigs: ['./config/config.default'],
    imports: ['test1', 'test2'],
  },
  properties: {
    ctx: {
      decorator: 'Inject',
    },
    config: {
      decorator: 'Config',
    },
    logger: {
      decorator: 'Logger',
    },
  },
  methods: {
    onReady: {
      async: true,
      params: [{ name: 'conatiner'}],
      block: [
        `console.log('test');`,
      ],
    },
  },
});
izr.dep('@midwayjs/decorator', '^1.0.0');
izr.output();
```
npm package: @midwayjs/command-core
Description: 基于插件生命周期 + hook的内核
Latest version: 2.1.0

# Command Hook Core

基于插件生命周期 + hook的内核

## 内核使用文档
```js
import { CommandCore } from '@midwayjs/fcli-command-core';
const core = new CommandCore({
    config: {                   // 会挂载到 core.coreInstance.config 上
        servicePath: baseDir,
    },
    commands: ['invoke'],       // 默认命令，多级命令依次传入数组
    service: this.spec,         // 会挂载到 core.coreInstance.service 上
    provider: 'providerName',   // 会比对与插件中的provider是都一致来决定插件是否加载
    options: this.argv,         // 参数，会作为第二个参数传递给插件构造函数，例如 { function: 'index' }
    log: console,               // 输出及错误捕获
    displayUsage: func          // 自定义如何展示帮助 displayUsage(commandsArray, usage, this)
});
core.addPlugin(Plugin);         // 载入插件，插件支持 class / 'npm:provider:packageName' / 'local:provider:path' 三种形式
await core.ready();             // 等待初始化
await core.invoke();            // 执行默认命令
```

**core.coreInstance** 会作为第一个参数传递给插件的构造函数，上面挂载了各种方法及属性，详见 [./src/interface/commandCore.ts](./src/interface/commandCore.ts#L25) ICoreInstance

**options** 作为第二个参数传递给插件构造函数


## 插件开发文档

提供了 `BasePlugin` 插件基类，可以继承此基类编写插件

```js
import BasePlugin from 'command-core/lib/plugin';
class Plugin extends BasePlugin {
    provider = 'test'                      // provider，在插件加载时会比对provider，如果存在此属性并且与配置的provider不相同，则不加载
    commands = {                           // 命令列表
        invoke: {                          // 命令，例如 f invoke
            usage: 'test provider invoke', // 使用提示
            lifecycleEvents: ['one', 'two']// 生命周期，在执行 invoke 命令时 会依次按照 lifecycleEvents 里面声明的hook进行触发
        }
    }
    hooks = { // hook采用 prefix:command:lifesycle 的形式，prefix 包含 before和after，分别代表在之前执行还是之后执行。lifesycle即命令中 lifecycleEvents 指定的，如果hooks中不存在对应的钩子，则会跳过此生命周期
        'before:invoke:one': () => { this.core.cli.log('before:invoke:one'); }, // 所有的hooks均支持 async
        'invoke:one': async () => { this.core.cli.log('invoke:one'); },
        'after:invoke:one': () => { this.core.cli.log('after:invoke:one'); },
        'before:invoke:two': async () => { this.core.cli.log('before:invoke:two'); },
        'invoke:two': () => { this.core.cli.log('invoke:two'); },
        'after:invoke:two': async () => { this.core.cli.log('after:invoke:two'); },
    }

    async asyncInit() {
        // 可选择的同步初始化，在插件加载后调用此方法进行初始化
    }
}

export default Plugin;
```


## 插件如何进行测试？

```js
import { CommandCore } from '@midwayjs/fcli-command-core';
const core = new CommandCore({
    provider: 'providerName',
    options: {},
    commands: ['invoke'],
    log: console
});
core.addPlugin(Plugin);         // 载入你的插件
await core.ready();             // 等待初始化
await core.invoke();            // 执行对应的命令
```
npm package: @midwayjs/component-postinstall
Description: **Guide**
Latest version: 1.0.5

# @midwayjs/component-postinstall

**Guide**

Add the following content in midway component package.json.

```
"scripts": {
  "postinstall": "mcp autoconf"
},
"dependencies": {
  "@midwayjs/component-postinstall": "1"
}
```
npm package: @midwayjs/consul
Description: midway consul
Author: Wang Bo
Latest version: 3.20.23

# midway-consul

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cookies
Description: midway cookies
Author: czy88840616
Latest version: 1.3.0

# Midway Cookies

继承了 [pillarjs/cookies](https://github.com/pillarjs/cookies) 和 Egg Cookies，为 koa/serverless 提供 cookie 操作的封装。

比原版多了加密，使用更安全的 aes-256-gcm 算法。

## 加密

@midwayjs/cookies 提供了一种替代的 `encrypt` 模式，如 `signed`。 加密 cookie 的值将根据密钥进行加密。 任何没有密钥的人都无法知道原始 cookie 的值。

```ts
import * as Cookies from '@midwayjs/cookies');
ctx.cookies = new Cookies(ctx, keys[, defaultCookieOptions[, defaultGetCookieOptions]]);
ctx.cookies.set('foo', 'bar', { encrypt: true });
ctx.cookies.get('foo', { encrypt: true });
```

**注意：你应该在 get 和 set 中成对使用加解密。**

## 初始化

初始化时需要传递 Array 类型 的keys 参数，否则无法使用 cookies 的 `signed` 和 `encrypt` 功能。

每次设置或读取 signed cookie 或者 encrypt cookie 的时候，会用 keys 进行加密。每次加密都通过 keys 数组的第一个 key 进行加密，解密会从先到后逐个 key 尝试解密。读取 signed cookie 时，如果发现不是用第一个 key 进行加密时，会更新签名为第一个 key 加密的值。读取 encrypt cookie 时不会进行更新操作。

## 设置 cookie

通过 `cookies.set(key, value, options)` 的方式来设置一个 cookie。其中 options 支持的参数有：

- path - `String` cookie 的有效路径，默认为 `/`。
- domain - `String` cookie 的有效域名范围，默认为 `undefined`。
- expires - `Date` cookie 的失效时间。
- maxAge - `Number` cookie 的最大有效时间，如果设置了 maxAge，将会覆盖 expires 的值。
- secure - `Boolean` 是否只在加密信道中传输，注意，如果请求为 http 时，不允许设置为 true https 时自动设置为 ture。
- httpOnly - `Boolean` 如果设置为 ture，则浏览器中不允许读取这个 cookie 的值。
- overwrite - `Boolean` 如果设置为 true，在一个请求上重复写入同一个 key 将覆盖前一次写入的值，默认为 false。
- signed - `Boolean` 是否需要对 cookie 进行签名，需要配合 get 时传递 signed 参数，此时前端无法篡改这个 cookie，默认为 true。
- encrypt - `Boolean` 是否需要对 cookie 进行加密，需要配合 get 时传递 encrypt 参数，此时前端无法读到真实的 cookie 值，默认为 false。
- partitioned - `Boolean` 是否设置独立分区状态（[CHIPS](https://developers.google.com/privacy-sandbox/3pcd/chips)）的 Cookie。注意，只有 `secure` 为 true 的时候此配置才会生效。
- removeUnpartitioned - `Boolean` 是否删除非独立分区状态的同名 cookie。注意，只有 `partitioned` 为 true 的时候此配置才会生效。
- priority - `String` 设置 cookie 的 [优先级](https://developer.chrome.com/blog/new-in-devtools-81?hl=zh-cn#cookiepriority)，可选值为 `Low`、`Medium`、`High`，仅对 Chrome >= 81 版本有效。

## 读取 cookie

通过 `cookies.get(key, value, options)` 的方式来读取一个 cookie。其中 options 支持的参数有：

- signed - `Boolean` 是否需要对 cookie 进行验签，需要配合 set 时传递 signed 参数，此时前端无法篡改这个 cookie，默认为 true。
- encrypt - `Boolean` 是否需要对 cookie 进行解密，需要配合 set 时传递 encrypt 参数，此时前端无法读到真实的 cookie 值，默认为 false。

你也可以在初始化 Cookies 时通过 `defaultGetCookieOptions` 参数设置 `get` 方法的默认选项：

```ts
const cookies = new Cookies(ctx, keys, defaultCookieOptions, { signed: false });
// 现在 cookies.get('foo') 将默认使用 signed: false
```

**⚠️ 安全警告：在 `defaultGetCookieOptions` 中设置 `signed: false` 是非常危险的行为，因为它会默认禁用 cookie 签名验证。这会使你的应用容易受到 cookie 篡改攻击。只有在完全理解安全影响并有特定原因需要禁用签名验证的情况下，才应该使用此选项。**

## 删除 cookie

通过 `cookie.set(key, null)` 来删除一个 cookie。如果传递了 `signed` 参数，签名也会被删除。

## License

[MIT](LICENSE.txt)
npm package: @midwayjs/core
Description: midway core
Author: Harry Chen
Latest version: 3.20.23

# midway-core

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cos
Description: midway cos component
Author: czy88840616
Latest version: 3.20.23

# midwayjs cos module

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cron
Description: Midway Component for Cron
Author: Harry Chen
Latest version: 3.20.23

# midwayjs cron module

[![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)

this is a sub package for midway.

Document: [https://midwayjs.org](https://midwayjs.org)

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/cross-domain
Description: Midway Component for Cross Domain
Latest version: 3.20.23

## Cross-domain 跨域组件

适用于 `@midwayjs/faas` 、`@midwayjs/web` 、`@midwayjs/koa` 和 `@midwayjs/express` 多种框架的通用跨域组件，支持 `cors` 、`jsonp` 多种模式。

### Usage

1. 安装依赖
```shell
tnpm i @midwayjs/cross-domain --save
```
2. 在 configuration 中引入组件,
```ts
import * as crossDomain from '@midwayjs/cross-domain';
@Configuration({
  imports: [
    // ...other components
    crossDomain
  ],
})
export class AutoConfiguration {}
```



### CORS 配置
```ts
export const cors = {
  allowMethods: string |string[];
  origin: string|Function;
  exposeHeaders: string |string[];
  allowHeaders: string |string[];
  credentials: boolean|Function;
  keepHeadersOnError: boolean;
  maxAge: number;
}
```


### JSONP 配置
```ts
export const jsonp = {
  callback: 'jsonp',
  limit: 512,
}
```
npm package: @midwayjs/debugger
Description: Currency Debug
Author: Gao Yang
Latest version: 1.0.9

# debugger

通用的 debug 包裹，让一个方法有了单步调试的能力，可以用在 cli 等情况下支持 `--debug` 参数启动单步调试。

### Usage
```sh
npm i @midwayjs/debugger --save
```

```ts
// function.ts
import { debugWrapper } from '@midwayjs/debugger';
export const fun = async (arg1, arg2) => {
  await new Promise(resolve => setTimeout(resolve, 1000));
  return arg1 + arg2;
}

export const wrapFun = debugWrapper({
  file: __filename,           // 要包裹的方法所在文件
  export: 'fun',              // 要包裹的方法的方法名
  debug: process.env.DEBUG    // 是否开启debug，true即开启
});
```

## License

[MIT](http://github.com/midwayjs/debugger/blob/master/LICENSE)