@yunflyjs/yunfly-plugin-metadata
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-beta.14 • Public • Published

tace 插件

简介

  • 通过 metadata 透传数据

备注:

  • @yunflyjs/yunfly已内置此功能, 不需要单独引用。

使用

  1. 安装依赖
// 该插件依赖apm服务
yarn add @yunflyjs/yunfly-plugin-metadata
  1. config.plugin.ts 中声明插件
const plugins: { [key: string]: string }[] = [
  {
    name: 'metadata',
    package: '@yunflyjs/yunfly-plugin-metadata',
  },
];
export default plugins;
  1. config.default.ts 配置项 (可选)
// 该插件依赖 currentContext 能力
config.currentContext = {
  enable: true,
}

api 使用

import { Get } from '@yunflyjs/yunfly'
import { metadata } from '@yunflyjs/yunfly-plugin-metadata'


// 案例:Controller中使用
class SomeController {

  Get('/user')
  async getUser() {
    // 通过 metadata.add 添加
    metadata.add('name','zane');
    // 
    return true;
  }
}

Readme

Keywords

none

Package Sidebar

Install

npm i @yunflyjs/yunfly-plugin-metadata

Weekly Downloads

2

Version

0.0.1-beta.14

License

MIT

Unpacked Size

5.94 kB

Total Files

9

Last publish

Collaborators

  • wangweianger