# egg-yufu-gameops

> egg yufu gameops plugin

Latest version **0.0.2** (published 2020-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install egg-yufu-gameops
pnpm add egg-yufu-gameops
yarn add egg-yufu-gameops
bun add egg-yufu-gameops
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2020-12-17 |
| First published | 2020-12-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | tonyhe |
| Maintainers | tonykings |

## Links

- npm: https://www.npmjs.com/package/egg-yufu-gameops
- Repository: https://github.com/hokkoo/egg-yufu-gameops
- Homepage: https://github.com/hokkoo/egg-yufu-gameops#readme
- Issues: https://github.com/hokkoo/egg-yufu-gameops/issues
- npm.io page: https://npm.io/package/egg-yufu-gameops

## Dependencies (1)

- [Base64](https://npm.io/package/Base64.md) ^1.1.0

## Recent versions

- 0.0.2 (latest) — 2020-12-17
- 0.0.1 — 2020-12-16

## README

# egg-yufu-gameops

egg-yufu-gameops plugin 工作台玉符插件

<!--
Description here.
-->

## 依赖说明

### 依赖的 egg 版本

## 开启插件

```js
// config/plugin.js
exports.yufu = {
	enable: true,
	package: 'egg-yufu-gameops',
};

```

## 使用场景

- 通过工作台网关，可以使用此插件，获取访问用户的信息

- 使用方式，安装后，启用插件，并参考下面的详细配置

## 详细配置

请到 [config/config.default.js](config/config.default.js) 查看详细配置项说明。
```js
// config/config.*.js
module.exports = {
		yufu: {
			header: {
				userId: 'x-user-id', // 用户id的请求头字段
				userName: 'x-user-name', // 用户名的请求头字段
			},
			verifyHeader: (headers) => { return true }, // 校验：校验请求头；
			verifyUser: ({ userId, userName }) => { return true }, // 校验：校验解析出来的用户信息；
			default_id: 1, //	无法解析时默认返回的	id
			default_user: 'rtx-name', //	无法解析时默认返回的	user
			exclude: path => !path, // 判断输入的路径是否为要排除的目录
			handleError: ({ ctx, ret, msg }) => { ctx.body = { ret, msg }; }, // 如何处理错误
			processHeader: (headers) => { return  {}; }, // 自定义header处理，最终数据会加到返回的用户信息里
		},
};
```

### 获取当前用户信息
```js
ctx.yufu; // { userId // 用户ID, userName // 用户名, headers // 请求头原始数据 }

```

## 提问交流

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/egg-yufu-gameops · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
