open-index/open-npm huggingface dataset:
npm package: @midwayjs/mikro
Description: this is a sub package for midway.
Author: czy88840616
Latest version: 3.20.23

# midway Mikro component

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/mininm
Description: Minimal node_modules
Author: echosoar
Latest version: 1.0.4

<p align="center">
  <br/>
  <br/>
  <b>mininm</b>
  <br />
  <br />
  <span>移除 <b>node_modules</b> 中数以万计的无用文件</span>
  <br />
  <br />
  <span>
    <a href="https://www.npmjs.org/package/@midwayjs/mininm"><img src="https://img.shields.io/npm/v/@midwayjs/mininm.svg?style=flat" alt="npm"></a> 
    <a href="./LICENSE" alt="GitHub license">
      <img src="https://img.shields.io/badge/license-MIT-blue.svg" />
    </a>
    <a href="https://github.com/echosoar/@midwayjs/mininm/actions?query=workflow%3A%22Node.js+CI%22" alt="Node.js CI">
      <img src="https://img.shields.io/badge/Node.js%20CI-passing-brightgreen" />
    </a>
  </span>
  <br />
  <br />
</p>

## Use In Command
```shell
$ npm i @midwayjs/mininm -g
$ mininm
```

## Use In Code

```shell
$ npm i @midwayjs/mininm -S
```

```TS
import { removeUselessFiles, removeUselessDirs } from '@midwayjs/mininm';

await removeUselessFiles(baseDir);
await removeUselessDirs(baseDir);
```
npm package: @midwayjs/mock
Description: create your test app from midway framework
Author: Harry Chen
Latest version: 3.20.23

# midway-mock

[![Package Quality](http://npm.packagequality.com/shield/midway-mock.svg)](http://packagequality.com/#?package=midway-mock)
[![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/mongoose
Description: Midway Component for mongoose
Author: czy88840616@gmail.com
Latest version: 3.20.23

# midwayjs mongoose module

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/mongoose.svg)](http://packagequality.com/#?package=@midwayjs/mongoose)
[![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/mqtt
Description: Midway Framework for mqtt
Author: Harry Chen
Latest version: 3.20.23

# midway framework for mqtt

[![Package Quality](http://npm.packagequality.com/shield/midway-web.svg)](http://packagequality.com/#?package=midway-web)
[![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/mw-util
Description: 将 egg 插件变为 midway 组件的工具包，包含两个方法。
Latest version: 1.0.5

# egg mock util

将 egg 插件变为 midway 组件的工具包，包含两个方法。

使用方式如下，比如在 configuration 里，由于 egg 的目录是固定的，所以使用文件加载的形式直接执行即可。

```ts
import { completeAssign, createMockApp } from '@midwayjs/mw-util';

export class AutConfiguration {
  @App()
  app;

  async onReady() {
    // 创建一个 egg 认识的模拟 app
    const mockApp = createMockApp(this.app);
    // 执行 egg 的 app.js 中的方法
    require('@ali/egg-********/app')(mockApp);

    // 执行 beforeStart 方法
    await Promise.all(mockApp.getBeforeStartList());

    // 可选：将 egg 赋到 app 上的对象拿到，比如赋给 midway 的 app
    this.app.changefree = mockApp.changefree;

    // 用于合并 egg 的 context 方法，这样就有 ctx.xxx 方法了
    completeAssign(
      this.app.context,
      require('@ali/egg--********//app/extend/context')
    );
  }
}
```
npm package: @midwayjs/orm
Description: ## How to use
Author: Kurten Chan
Latest version: 3.4.3

# midway orm component

## How to use

in Configuration.ts file

```ts
import * as orm from '@midwayjs/orm';
import { join } from 'path';

@Configuration({
  imports: [
    orm,
  ],
  importConfigs: [
    join(__dirname, './config')
  ]
})
export class ContainerConfiguration {
}

```

## Configuration

in config files

```ts
export default {
  orm: {
    type: 'mysql',
    host: '',
    port: 3306,
    username: '',
    password: '',
    database: undefined,
    synchronize: true,
    logging: false,
 }
};
```

or

```ts
export const orm = {
  type: 'sqlite',  // or use mysql see typeorm docs
  database: join(__dirname, './test.sqlite'),
  logging: true,
}
```

## Define EntityModel

```ts
// model/user.ts
import { EntityModel } from '@midwayjs/orm';
import { PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';

@EntityModel('test_user')
export class Photo {
  @PrimaryGeneratedColumn({ name: "id" })
  id: number;

  @Column({ name: "name" })
  name: string;

  @OneToMany(type => Message, message => message.sender)
  messages: Message[];
}
```


## Use Model

in code files

```ts
import { InjectEntityModel } from '@midwayjs/orm';
import { User } from './model/user';
import { Repository } from 'typeorm';

@Provide()
export class UserService {

  @InjectEntityModel(User)
  userModel: Repository<User>;

  async testUser() {
    const u = new User();
    u.name = 'oneuser1';
    const uu = await this.userModel.save(u);
    console.log('user one id = ', uu.id);

    const user = new User();
    user.id = 1;
    const users = await this.userModel.findAndCount(user);
    return 'hello world' + JSON.stringify(users);
  }
}
```
npm package: @midwayjs/oss
Description: midway oss component
Author: czy88840616
Latest version: 3.20.23

# midwayjs oss 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/otel
Description: midway open telemetry component
Author: czy88840616
Latest version: 3.20.23

# 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 { NodeSDK, node, resources } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
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 node.ConsoleSpanExporter();
const sdk = new NodeSDK({
  resource: new resources.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()

// 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));
});

Bootstrap
  .configure(/**/)
  .run();

```

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/core';
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]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/ots
Description: midway ots component
Author: czy88840616
Latest version: 2.13.0

# midwayjs ots 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/midway](https://midwayjs.org/midway)

## License

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

### 自定义方法

定义 Histogram 方法：
```
@Configuration({
  imports: [
    koa,
    validate,
    prometheus,
    {
      component: info,
      enabledEnvironment: ['local'],
    },
  ],
  importConfigs: [join(__dirname, './config')],
})
export class ContainerLifeCycle {
  @App()
  app: koa.Application;

  async onReady() {
    const result = await this.app.getApplicationContext().getAsync(DataService);
    // 此处定义了一个名字叫 test_histogram 的 Histogram
    result.define('test_histogram', 'Histogram', {
      help: '132',
      name: 'test_histogram',
      buckets: [5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000],
    });
  }
}
```

为了测试这个Histogram，我们在一个接口里面：
```
import { Inject, Controller, Get, Query } from '@midwayjs/decorator';
import { Context } from '@midwayjs/koa';
import { DataService } from '@midwayjs/prometheus';
import { UserService } from '../service/user.service';

@Controller('/api')
export class APIController {
  @Inject()
  ctx: Context;

  @Inject()
  userService: UserService;

  @Inject()
  dataService: DataService;

  @Get('/get_user')
  async getUser(@Query('uid') uid) {
    this.dataService.observe('test_histogram', [], 100); //此处我们observe了这个histogram
    const user = await this.userService.getUser({ uid });
    return { success: true, message: 'OK', data: user };
  }
}
```

然后访问这个接口，然后我们查看我们 /metrics 的接口返回:
```
# HELP test_histogram 132
# TYPE test_histogram histogram
test_histogram_bucket{le="5",APP_NAME="default"} 0
test_histogram_bucket{le="10",APP_NAME="default"} 0
test_histogram_bucket{le="25",APP_NAME="default"} 0
test_histogram_bucket{le="50",APP_NAME="default"} 0
test_histogram_bucket{le="100",APP_NAME="default"} 1
test_histogram_bucket{le="250",APP_NAME="default"} 1
test_histogram_bucket{le="500",APP_NAME="default"} 1
test_histogram_bucket{le="1000",APP_NAME="default"} 1
test_histogram_bucket{le="2500",APP_NAME="default"} 1
test_histogram_bucket{le="5000",APP_NAME="default"} 1
test_histogram_bucket{le="10000",APP_NAME="default"} 1
test_histogram_bucket{le="+Inf",APP_NAME="default"} 1
test_histogram_sum{APP_NAME="default"} 100
test_histogram_count{APP_NAME="default"} 1
```

至此，已经我们想要的自定义 Histogram 了。
npm package: @midwayjs/rabbitmq
Description: Midway Framework for rabbitmq
Author: Harry Chen
Latest version: 3.20.23

# midway framework for rabbitmq

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

this is a sub package for midway.

this module use [amqplib](https://github.com/squaremo/amqp.node)

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

## License

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

# 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]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/sequelize
Description: this is a sub package for midway.
Author: stone-jin
Latest version: 3.20.23

# midway sequelize component

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/serverless-aws-starter
Description: this module is a light runtime starter for amazon lambda.
Latest version: 3.4.0

# serverless aws starter

this module is a light runtime starter for amazon lambda.

```ts
import { asyncWrapper, createRuntime } from '@midwayjs/serverless-aws-starter';

let runtime;
export.init = asyncWrapper(async () => {
  runtime = await createRuntime();
});

// for web request
export.handler = asyncWrapper(async (...args) => {
  return runtime.asyncEvent(async function(ctx) {
    return 'hello world';  // ctx.body = 'hello world';
  })(...args);
});

// for event
export.handler = asyncWrapper(async (...args) => {
  return runtime.asyncEvent(async function(ctx, event) {
    return {data: 1};
  })(...args);
});

```
npm package: @midwayjs/serverless-dev-pack
Description: 本模块用于 faas 代码的本地调试，用于接入现有的前端 DevServer，提供一个统一的中间件调用。
Latest version: 2.0.15

# Midway FaaS Dev

本模块用于 faas 代码的本地调试，用于接入现有的前端 DevServer，提供一个统一的中间件调用。