Skip to content

ChaofengYan/egg-green

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

egg-green

NPM version build status Test coverage David deps Known Vulnerabilities npm download

安装

$ npm i egg-green --save

使用

// {app_root}/config/plugin.js
exports.green = {
  enable: true,
  package: 'egg-green',
};

ctx上挂载green变量,通过ctx.green[类型][方法](参数)使用,其中类型textimagevideofilevoice 5种,方法可参考阿里云内容安全产品文档

module.exports = class extends Controller {
  async textScan() {
    const ctx = this.ctx;
    
     ctx.body = = await ctx.green.text.scan({
      bizType: 'homon',
      scenes: [ 'antispam' ],
      tasks,
    });
  }
};

配置

// {app_root}/config/config.default.js
exports.green = {
  accessKeyId: 'your access key',  // 必选
  accessKeySecret: 'your access secret', // 必选
  endpoint: 'https://green.cn-shanghai.aliyuncs.com' // 可选
  bizType: 'xx', // 业务场景,在「阿里云控制台 -> 内容安全 -> 设置 -> 内容检测API」中查看或新增
};

License

MIT

About

阿里云内容安全,egg插件

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published