@axolo/egg-dingtalk

0.0.2 • Public • Published

egg-dingtalk

node-dingtalk plugin for Egg.js.

Install

npm i @axolo/egg-dingtalk --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.dingtalk = {};

see https://github.com/axolo/node-dingtalk for more help. see config/config.default.js for more detail.

Config client or clients as you like:

dingtalk corp app:

{ client: { appKey, appSecret, agentId } }

dingtalk isv suite with single app:

{ client: { suiteKey, suiteSecret, appId } }

dingtalk isv suite with multiple apps:

{
  client: {
    suiteKey,
    suiteSecret,
    apps: [ { appId }, { appId } ],
  }
}

dingtalk isv suite with multiple apps per app:

{
  clients: {
    app1: { suiteKey, suiteSecret, appId },
    app2: { suiteKey, suiteSecret, appId },
  },
}

Example

const Controller = require('egg').Controller;

class DingtalkController extends Controller {
  async index() {
    const { app, ctx } = this;
    const { dingtalk } = app;
    const corpId = 'CORP_ID';
    const params = { id: 1 };
    const result = await dingtalk.execute('/department/get', { params }, { corpId });
    ctx.body = result;
  }
}

module.exports = DingtalkController;

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @axolo/egg-dingtalk

Weekly Downloads

1

Version

0.0.2

License

MIT

Unpacked Size

8.05 kB

Total Files

6

Last publish

Collaborators

  • axolo