open-index/open-npm huggingface dataset:
npm package: @midwayjs/deno-mocha
Description: Run your existing mocha tests with Deno.
Author: The Midway Authors
Latest version: 1.3.0

# deno-mocha

Run your existing mocha tests with Deno.

## Setup

Setup dependencies:

```
$ npm install @midwayjs/deno-mocha --save-dev
```

Run your tests with deno-mocha:

```
$ deno-mocha 'test/**/*.test.ts'
```

## Explainer

For testing convenience, the runner has also included the following popular testing module maps:

- assert: <https://deno.land/std@0.139.0/node/assert.ts>

## License

MIT.
npm package: @midwayjs/dev-pack
Description: Midway Fullstak Dev Pack
Author: Lxxyx
Latest version: 3.1.6

# @midwayjs/dev-pack

Express

```js
import { createExpressDevPack } from '@midwayjs/dev-pack';
import express from 'express';

const { middleware } = await createExpressDevPack({
  cwd: process.cwd(),
  sourceDir: resolve(process.cwd(), 'src'),
  watch: true,
});

const app = express();
app.use(middleware);
app.listen(3000);
```
npm package: @midwayjs/egg
Latest version: 1.2.1

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

# midwayjs etcd 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/event-emitter
Description: midway event emitter component
Author: czy88840616
Latest version: 4.0.2

# midwayjs etcd 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/express
Description: Midway Web Framework for Express
Author: Harry Chen
Latest version: 3.20.23

# midway for express

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

# @midwayjs/express-session

Session component for @midwayjs/express


## Install

```bash
$ npm i @midwayjs/express-session --save
$ npm i @types/express-session --save-dev
```


## Usage

@midwayjs/express has enabled this component by default.

We use [cookie-session](https://github.com/expressjs/cookie-session) to keep session by default and use [express-session](https://github.com/expressjs/session) when set custom session store.

## Config

You can configure session in your `config.*.ts`.

default value.

```ts
export const session = {
  secret: undefined, // must be set in application
  name: 'MW_SESS',
  cookie: {
    maxAge: 24 * 3600 * 1000, // ms
    httpOnly: true,
    // sameSite: null,
  },
};
```

You can set 'session.cookie' for cookie-session config.

## Custom Session Store

You can use compatible session store [here](https://github.com/expressjs/session#compatible-session-stores).

Let's give an example for [memorystore](https://github.com/roccomuso/memorystore).

```ts
import { Configuration, Inject } from '@midwayjs/core';
import * as session from '@midwayjs/express-session';
import MemoryStore = require('memorystore');

@Configuration({
  imports: [
    express,
    session,
  ],
  //...
})
export class AutoConfiguration {
  @Inject()
  sessionStoreManager: session.SessionStoreManager;

  async onReady() {
    this.sessionStoreManager.setSessionStore(MemoryStore, {
      checkPeriod: 86400000 // prune expired entries every 24h
    });
  }
}
```

Another example for [connect-redis](https://github.com/tj/connect-redis).

```ts
import { Configuration, Inject } from '@midwayjs/core';
import * as session from '@midwayjs/express-session';
import RedisStore from "connect-redis"
import {createClient} from "redis"

// Initialize client.
let redisClient = createClient()
redisClient.connect().catch(console.error)

@Configuration({
  imports: [
    express,
    session,
  ],
  //...
})
export class AutoConfiguration {
  @Inject()
  sessionStoreManager: session.SessionStoreManager;

  async onReady() {
    // Initialize store.
    this.sessionStoreManager.setSessionStore(RedisStore, {
      client: redisClient,
      prefix: "myapp:",
      // ...
    });
  }
}
```

## Questions & Suggestions

Please open an issue [here](https://github.com/midwayjs/midway/issues/).

## License

MIT
npm package: @midwayjs/faas
Description: ![](https://img.alicdn.com/tfs/TB1HdniCSf2gK0jSZFPXXXsopXa-1000-353.png)
Latest version: 3.20.23

# Midway FaaS

![](https://img.alicdn.com/tfs/TB1HdniCSf2gK0jSZFPXXXsopXa-1000-353.png)

<p align="center">
  <a href="https://www.npmjs.com/package/@midwayjs/faas" alt="npm version">
    <img src="https://img.shields.io/npm/v/@midwayjs/faas.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-faas/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/midway-faas" alt="Activity">
    <img src="https://img.shields.io/github/commit-activity/m/midwayjs/midway-faas" />
  </a>
  <a href="https://github.com/midwayjs/midway-faas/graphs/contributors" alt="Contributors">
    <img src="https://img.shields.io/github/contributors/midwayjs/midway-faas" />
  </a>
  <a href="https://gitpod.io/#https://github.com/midwayjs/midway-faas" alt="Gitpod Ready-to-Code">
    <img src="https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod" />
  </a>
</p>

Midway FaaS is the Serverless framework used to build Node.js cloud functions. Helps you significantly reduce maintenance costs and focus more on product development in the cloud-native era.

- **Cross-cloud vendor**: One code can be deployed quickly across multiple cloud platforms, so you don't have to worry about your product being tied to a cloud vendor.
- **Code reuse**: Through the framework's dependency injection capability, each part of the logical unit is naturally reusable and can be quickly and easily combined to generate complex applications.
- **Traditional Migration**: Through the framework's runtime scalability, traditional applications such as Egg.js, Koa, Express.js and others can be seamlessly migrated to the cloud functions of various cloud vendors.

## Document

- Guide [中文](https://www.yuque.com/midwayjs/faas) and [English](https://www.yuque.com/midwayjs/faas/quick_start?translate=en)

## License

Midway FaaS is [MIT licensed](./LICENSE).
npm package: @midwayjs/fc-starter
Description: 本模块用于包裹无法定制运行时的 FaaS 平台，比如阿里云 FC。
Latest version: 3.20.23

# serverless fc starter

本模块用于包裹无法定制运行时的 FaaS 平台，比如阿里云 FC。

## 阿里云 FC

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

let runtime;
exports.init = asyncWrapper(async () => {
  runtime = await start();
});

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

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

```
npm package: @midwayjs/glob
Description: 实现一个基础轻量的 globby，为了兼容 faas-glob 语法，引入纯 js 版的 picomatch 库，除此之外，无其他依赖。
Latest version: 1.1.1

# midway easy glob tools

实现一个基础轻量的 globby，为了兼容 faas-glob 语法，引入纯 js 版的 picomatch 库，除此之外，无其他依赖。

## API

```ts
import { run } from '@midwayjs/glob';

const result = run(['**/*.md'], {
  cwd: join(__dirname, './fixtures/first'),
  ignore: [
    '**/c.md',
    '**/bbbb/**'
  ]
});
console.log(result); // Output: [ '/Users/harry/project/glob/test/fixtures/first/a.md' ]

```
npm package: @midwayjs/grpc
Description: Midway Framework for gRPC
Author: Harry Chen
Latest version: 3.20.23

# @midwayjs/grpc

Grpc component for midway.

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/grpc-helper
Description: Midway gRPC helper
Author: Harry Chen
Latest version: 1.1.0

# Midway gRPC interface generator

code fork from https://github.com/AlexDaSoul/nestjs-proto-gen-ts


## Installation

```bash
$ npm install @midwayjs/grpc-helper --save-dev
```


## Example

Protobuf file hero-proto/hero.proto:

```proto
syntax = "proto3";

package hero;

service HeroesService {
  rpc FindOne (HeroById) returns (Hero) {}
}

message HeroById {
  int32 id = 1;
}

message Hero {
  int32 id = 1;
  string name = 2;
}
```

Generate interfaces:

```bash
$ tsproto --path ./hero-proto
```

Output:

```ts
import * as grpc from '@midwayjs/grpc';

export namespace hero {
  export interface HeroService {
    findOne(data: HeroById): Promise<Hero>;
  }
  /**
   * HeroService client interface
   */
  export interface HeroServiceClient {
    findOne(options?: grpc.IClientOptions): grpc.IClientUnaryService<HeroById, Hero>;
  }
  export interface HeroById {
    id?: number;
  }
  export interface Hero {
    id?: number;
    name?: string;
  }
}


```

## Usage

Base usage:
```bash
$ tsproto --path grpc-proto
```
Output dir:
```bash
$ tsproto --path grpc-proto --output any-dir
```
Target files:
```bash
$ tsproto --path grpc-proto --target one.proto two.proto
```
Ignore directories or files:
```bash
$ tsproto --path grpc-proto --ignore grpc-proto/ignore-dir
```

## Options

The following options are available:

```
  --version, -v   Show version number                                  [boolean]
  --help, -h      Show help                                            [boolean]
  --path, -p      Path to root directory                      [array] [required]
  --output, -o    Path to output directory                              [string]
  --target, -t    Proto files                      [array] [default: [".proto"]]
  --ignore, -i    Ignore file or directories
                                      [array] [default: ["node_modules","dist"]]
  --comments, -c  Add comments from proto              [boolean] [default: true]
  --verbose       Log all output to console            [boolean] [default: true]
  --keepCase, -k  keep property case                   [boolean] [default: true]
```
npm package: @midwayjs/http-proxy
Description: Midway Component for http proxy
Latest version: 3.20.23

## HTTP 代理组件

HTTP 代理组件

适用于 `@midwayjs/faas` 、`@midwayjs/web` 、`@midwayjs/koa` 和 `@midwayjs/express` 多种框架的 HTTP 代理组件，支持GET、POST等多种请求方法。

### Usage

1. 安装依赖

```bash
$ npm i @midwayjs/http-proxy --save
```

2. 在 configuration 中引入组件,
```ts
import * as proxy from '@midwayjs/http-proxy';
@Configuration({
  imports: [
    // ...other components
    proxy
  ],
})
export class AutoConfiguration {}
```

### 配置

```ts
export const httpProxy = {
  host: 'http://127.0.0.1',
  match: /\/assets\/(.*)/,
  target: 'http://127.0.0.1/$1',
}
```
npm package: @midwayjs/info
Description: midway info
Author: czy88840616
Latest version: 3.20.23

# Midway Information Component

Show your project info in router or other way, like phpInfo.

![info](https://img.alicdn.com/imgextra/i3/O1CN01TCkSvr28x8T7gtnCl_!!6000000007998-2-tps-797-1106.png)

## Usage

import info component in `configuration.ts` file

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

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

```

Your can curl `/_info` to show it.

## License

[MIT]((https://github.com/midwayjs/midway/blob/master/LICENSE))