open-index/open-npm huggingface dataset:
npm package: @midwayjs/static-file
Description: midway static file component
Author: czy88840616
Latest version: 3.20.23

# Midway Static File Component

Static server plugin for egg, base on [koa-static-cache](https://github.com/koajs/static-cache).

## Install

```bash
$ npm i @midwayjs/static-file --save
```

available in koa/egg/faas.

## Usage

import info component in `configuration.ts` file

```ts
import * as koa from '@midwayjs/koa';
import * as staticFile from '@midwayjs/static-file';
import { join } from 'path';

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

```

support all configurations in [koa-static-cache](https://github.com/koajs/static-cache). and with default configurations below:

- dynamic: `true`
- preload: `false`
- maxAge: `31536000` in prod env, `0` in other envs
- buffer: `true` in prod env, `false` in other envs

provides one more option:

- maxFiles: the maximum value of cache items, only effective when dynamic is true, default is `1000`.

**All static files in `$appDir/public` can be visited with prefix `/public`, and all the files are lazy loaded.**

- In non-production environment, assets won't be cached, your modification can take effect immediately.
- In production environment, `@midwayjs/static-file` will cache the assets after visited, you need to restart the process to update the assets.
- Dir default is `$appDir/public` but you can also define **multiple directory** by default, static server will use all these directories.

```js
// {app_root}/src/config/config.default.ts
export const staticFile = {
  dirs: {
    default: {
      prefix: '/public',
      dir: 'xxx'
    },
    antoherDir: {
      prefix: '/',
      dir: 'xxx'
    }
  }
};
```

if you want to override default prefix, just set `dirs.default`.

```js
// {app_root}/src/config/config.default.ts
export const staticFile = {
  dirs: {
    default: {
      prefix: '/',
    },
  }
};
```


## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))
npm package: @midwayjs/swagger
Description: ## Thanks to [@nestjs/swagger](https://github.com/nestjs/swagger)
Author: Kurten Chan
Latest version: 3.20.23

# midway swagger module

## Thanks to [@nestjs/swagger](https://github.com/nestjs/swagger)

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/tablestore
Description: midway tablestore component
Author: czy88840616
Latest version: 3.20.23

# midwayjs tablestore 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/tenant
Description: midway tenant component
Author: czy88840616
Latest version: 3.20.23

# midwayjs tenant 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/ts-analysis
Description: @midwayjs/ts-analysis
Author: echosoar
Latest version: 0.1.8

# ts-analysis
Analysis TypeScript Code to Json

<p align="center">
  <a href="https://www.npmjs.com/package/@midwayjs/ts-analysis" alt="npm version">
    <img src="https://img.shields.io/npm/v/@midwayjs/ts-analysis.svg?style=flat" />
  </a>
  <a href="./LICENSE" alt="GitHub license">
    <img src="https://img.shields.io/badge/license-MIT-blue.svg" />
  </a>
  <a href="https://github.com/midwayjs/midway-serverless/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>
  <a href="https://github.com/midwayjs/ts-analysis" alt="Activity">
    <img src="https://img.shields.io/github/commit-activity/m/midwayjs/ts-analysis" />
  </a>
  <a href="https://github.com/midwayjs/ts-analysis/graphs/contributors" alt="Contributors">
    <img src="https://img.shields.io/github/contributors/midwayjs/ts-analysis" />
  </a>
</p>

## Usage
```ts
// Use Class
import { TsAnalysis } from '@midwayjs/ts-analysis';

async (codePath) => {
  const analysisInstance = new TsAnalysis(codePath);    // 初始化实例
  await analysisInstance.start();                       // 分析器启动
  const result = await analysisInstance.getResult();    // 获取分析结果
  return result;
}

// Use Instance
import { tsAnalysis } from '@midwayjs/ts-analysis';

async (codePath) => {
  const result = await tsAnalysis(codePath)             // 获取分析结果
  return result;
}
```

## Result Demo
### Decorator

```ts
// decorator.ts
@Provider()
class Test {

  constructor(name: string, age: number) {}

  @Inject('context')
  ctx;

  @Func('index.handler', { method: 'GET', path: '/api/test' })
  async handler() { }
}

// result
{
  decorators: {
    Provider: [
      {
        sourceFile: '/Users/xxx/decorator.ts',  // 代码所在位置
        position: {                             // 装饰器所在位置
          start: {                              // 装饰器开始位置
            ln: 0,
            col: 0
          },
          end: {                                // 装饰器结束位置
            ln: 0,
            col: 12
          }
        },
        params: [
          // 参数
        ],
        target: {                               // 装饰的目标
          type: 'class',                        // 目标类型
          name: 'Test',                         // 目标名称
          position: {                           // 目标代码位置
            ... // 格式参照上述位置结构
          },
          params: [                             // 目标参数列表，class即为constructor参数列表
            { 
              name: 'name',
              type: 'string'
            },
            { 
              name: 'age',
              type: 'number'
            }
          ]
        },
        childDecorators: {
          Inject: [
            ... // 结构类似
          ],
          Func: [
            ... // 结构类似
          ]
        }
      }
    ],
    Inject: [
      ... // 结构类似
    ],
    Func: [
      ... // 结构类似
    ]
  }

}
```
npm package: @midwayjs/typeorm
Description: ## How to use
Author: czy88840616
Latest version: 3.20.23

# midway typeorm component

## How to use

in Configuration.ts file

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

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

```

## Configuration

in config files

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

## Define EntityModel

```ts
// model/user.ts
import { Entity, PrimaryGeneratedColumn, Column, OneToMany } from 'typeorm';

@Entity('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({
      where: user
    });
    return 'hello world' + JSON.stringify(users);
  }
}
```
npm package: @midwayjs/upload
Description: Midway Component for upload
Latest version: 3.20.23

## Upload 上传组件

适用于 `@midwayjs/faas` 、`@midwayjs/web` 、`@midwayjs/koa` 和 `@midwayjs/express` 多种框架的通用上传组件，支持 `file` (服务器临时文件)、`stream` （流）多种模式。

### Usage

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

3. 在代码中获取上传的文件
```ts
@Controller('/')
export class HomeController {

  @Inject()
  ctx;

  @Post('/upload')
  async upload(@Files() files: upload.UploadFileInfo[], @Fields() fields) {
    /*
    files = [
      {
        filename: 'test.pdf',        // 文件原名
        data: '/var/tmp/xxx.pdf',    // mode 为 file 时为服务器临时文件地址
        fieldName: 'test1',          // 表单 field 名
        mimeType: 'application/pdf', // mime
      },
      {
        filename: 'test.pdf',        // 文件原名
        data: ReadStream,    // mode 为 stream 时为服务器临时文件地址
        fieldName: 'test2',          // 表单 field 名
        mimeType: 'application/pdf', // mime
      },
      // ...file 下支持同时上传多个文件
    ]

    */
    return {
      files,
      fields
    }
  }
}
```


### 配置
```ts
export const upload = {
  // mode: UploadMode, 默认为file，即上传到服务器临时目录，可以配置为 stream
  mode: 'file',
  // fileSize: string, 最大上传文件大小，默认为 10mb
  fileSize: '10mb',
  // whitelist: string[]，文件扩展名白名单，默认为 null
  whitelist: null,
  // tmpdir: string，上传的文件临时存储路径
  tmpdir: join(tmpdir(), 'midway-upload-files'),
  // cleanTimeout: number，上传的文件在临时目录中多久之后自动删除，默认为 5 分钟
  cleanTimeout: 5 * 60 * 1000,
  // base64: boolean，设置原始body是否是base64格式，默认为false，一般用于腾讯云的兼容
  base64: false,
}
```
npm package: @midwayjs/validate
Description: Midway Component for mongoose
Author: czy88840616@gmail.com
Latest version: 3.20.23

# midway validate module

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

# midway validate module

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/validate.svg)](http://packagequality.com/#?package=@midwayjs/validate)
[![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/validation-joi
Description: Midway Component for validation and use joi as validation tool
Author: czy88840616@gmail.com
Latest version: 4.0.2

# midway joi for validate module

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/validate.svg)](http://packagequality.com/#?package=@midwayjs/validate)
[![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/validation-zod
Description: Midway Component for validation and use zod as validation tool
Author: Harry Chen
Latest version: 4.0.2

# midway zod for validate module

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/zod.svg)](http://packagequality.com/#?package=@midwayjs/zod)
[![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/validation-zod4
Description: Midway Component for validation and use zod as validation tool
Author: Harry Chen
Latest version: 4.0.2

# midway zod for validate module（zod4）

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/zod.svg)](http://packagequality.com/#?package=@midwayjs/zod)
[![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/view-ejs
Description: Midway Component for ejs render
Latest version: 3.20.23

# midway-view-ejs

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/view-ejs.svg)](http://packagequality.com/#?package=@midwayjs/view-ejs)
[![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/view-nunjucks
Description: Midway Component for nunjucks render
Latest version: 3.20.23

# midway-view-nunjucks

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/view-nunjucks.svg)](http://packagequality.com/#?package=@midwayjs/view-nunjucks)
[![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/vue
Description: Midway Vue API bridge component
Author: Midway Team
Latest version: 4.0.2

# @midwayjs/vue

Vue-specific integration for Midway functional API.

## Install

```bash
npm i @midwayjs/vue @midwayjs/web-bridge
```

```json
{
  "dependencies": {
    "@midwayjs/vue": "^4.0.0-beta.11",
    "@midwayjs/web-bridge": "^4.0.0-beta.11"
  }
}
```

## Usage

```ts
import { createApp } from 'vue';
import { createMidwayApiPlugin } from '@midwayjs/vue';
import { api } from './api/client';
import App from './App.vue';

createApp(App).use(createMidwayApiPlugin(api)).mount('#root');
```

```ts
import { useMidwayApiOperation } from '@midwayjs/vue';

const callGetUser = useMidwayApiOperation<{ params: { id: string } }, { id: string }>('user.getUser');
await callGetUser({ params: { id: '1' } });
```
npm package: @midwayjs/web
Description: Midway Web Framework for Egg.js
Author: Harry Chen
Latest version: 3.20.23

# @midwayjs/web

[![Package Quality](http://npm.packagequality.com/shield/@midwayjs/web.svg)](http://packagequality.com/#?package=@midwayjs/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/web-bridge
Description: Midway web bridge for API contract client and build transforms
Author: Midway Team
Latest version: 4.0.2

# @midwayjs/web-bridge

Framework-neutral bridge for Midway functional API client/runtime and build-time transforms.

## Install

```bash
npm i @midwayjs/web-bridge
```

```json
{
  "dependencies": {
    "@midwayjs/web-bridge": "^4.0.0-beta.11"
  }
}
```

## Runtime client

```ts
import { createClient } from '@midwayjs/web-bridge';
import { userApi } from '@/server/api/user.api';

export const api = createClient(
  { user: userApi },
  { basePath: '/api' }
);
```

## Vite transform plugin

```ts
import { apiPlugin } from '@midwayjs/web-bridge/vite';

apiPlugin({
  root: process.cwd(),
  apiDir: 'src/server/api',
  target: 'both',
});
```

## Rspack transform rule

```ts
import { createApiRspackRule } from '@midwayjs/web-bridge/rspack';

createApiRspackRule({
  root: process.cwd(),
  apiDir: 'src/server/api',
});
```
npm package: @midwayjs/ws
Description: Midway Web Framework for ws
Author: Harry Chen
Latest version: 3.20.23

# midway framework for WebSocket

[![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))