open-index/open-npm huggingface dataset:
npm package: @midwayjs/serverless-scf-starter
Description: 本模块用于包裹无法定制运行时的 FaaS 平台，比如腾讯云 SCF。
Latest version: 3.4.0

# Serverless SCF starter

本模块用于包裹无法定制运行时的 FaaS 平台，比如腾讯云 SCF。

## 腾讯云 SCF

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

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

// 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-spec-builder
Description: FaaS 标准 Spec 解析工具，以及用于其他平台 spec 转换的基础定义。
Latest version: 2.1.0

# serverless spec builder

FaaS 标准 Spec 解析工具，以及用于其他平台 spec 转换的基础定义。

## API

**transform**

根据传入的标准 spec 文件和一个生成器类，转换成标准的 JSON 格式。

```ts
transform(sourcefilePath: string, builderCls?);
```

- sourcefilePath 原始 spec 文件地址
- builderCls 转换的 class(非实例)，默认为 SpecBuilder 类型，可以继承后传入

**generate**

```ts
generate(sourceFilePath: string, targetFilePath: string, builderCls?);
```

- sourcefilePath 原始 spec 文件地址
- targetFilePath 转换后的 spec 文件地址
- builderCls 转换的 class(非实例)，默认为 SpecBuilder 类型，可以继承后传入

**saveYaml**

保存 JSON 到 yml 文件

```ts
saveYaml(filePath: string, target：object);
```

- filePath 需要保存到的 yml 文件路径
- 保存到 yml 文件的 JSON 内容
npm package: @midwayjs/serverless-worker-starter
Description: 本模块用于包裹无法定制运行时的 FaaS 平台，比如阿里云 FC。
Latest version: 3.13.1

# serverless worker starter

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

## Serverless Worker

```ts
import { eventWaitUntil, eventRespondWith, start } from '@midwayjs/serverless-worker-starter';

let runtime;
addEventListener('install', eventWaitUntil(async event => {
  runtime = await start();
}));

addEventListener('fetch', eventRespondWith(async event => {
  return runtime.asyncEvent(async function(ctx) {
    return 'hello world';  // ctx.body = 'hello world';
  })(event);
}));
```
npm package: @midwayjs/session
Description: midway session component for koa and faas
Author: czy88840616
Latest version: 3.20.23

# @midwayjs/session

Session component for @midwayjs/koa and @midwayjs/faas


## Install

```bash
$ npm i @midwayjs/session --save
```


## Usage

@midwayjs/koa has enabled this component by default, @midwayjs/faas needs to be manually enabled.

```bash
// src/configuration.ts

import { join } from 'path';
import * as faas from '@midwayjs/faas';
import * as session from '@midwayjs/session';

@Configuration({
  imports: [
    faas,
    session,
  ],
  // ...
})
export class ContainerLifeCycle implements ILifeCycle {}

```

## Config

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

default value.

```ts
export const session = {
  maxAge: 24 * 3600 * 1000, // ms
  key: 'mw.sess',
  httpOnly: true,
  encrypt: true,
  // sameSite: null,
  logValue: true,
};
```

you can use all config from koa-session.

## Custom Session Store

Write a session store class first, extends abstract `SessionStore` class.

```ts
import { SessionStore } from '@midwayjs/session';

@Provide()
@Scope(ScopeEnum.Singleton)
export class MemorySessionStore extends SessionStore {
  sessions = {};
  async get(key) {
    return this.sessions[key];
  }

  async set(key, value) {
    this.sessions[key] = value;
  }

  async destroy(key) {
    this.sessions[key] = undefined;
  }
}
```

add custom sessionStore to session component.

```ts
import { MemorySessionStore } from './store';
import * as session from '@midwayjs/session';

@Configuration({
  imports: [
    koa,
    session,
  ],
  //...
})
export class AutoConfiguration {
  @Inject()
  memoryStore: MemorySessionStore;

  @Inject()
  sessionStoreManager: session.SessionStoreManager;

  async onReady() {
    this.sessionStoreManager.setSessionStore(this.memoryStore);
  }
}
```

## Questions & Suggestions

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

## License

MIT
npm package: @midwayjs/socketio
Description: Midway Web Framework for socket.io
Author: Harry Chen
Latest version: 3.20.23

# midway framework for socket.io

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