@axolo/egg-wechat-mp

0.0.4 • Public • Published

egg-wechat-mp

@axolo/node-wechat-mp plugin for Egg.js.

Install

npm i @axolo/egg-wechat-mp --save

Usage

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

Configuration

// {app_root}/config/config.default.js
exports.wechatMp = {
  client: {
    appId: 'APP_ID',
    appSecret: 'APP_SECRET',
  },
};

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

Example

'use strict';

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

class WechatMpController extends Controller {
  async create() {
    const { app, ctx } = this;
    ctx.validate({ jsCode: 'string' });
    const { jsCode } = ctx.request.body;
    const wechatMp = app.wechatMp;
    const session = await wechatMp.code2session({ jsCode });
    ctx.body = session;
  }
}

module.exports = WechatMpController;

Questions & Suggestions

Please open an issue here.

License

MIT

Package Sidebar

Install

npm i @axolo/egg-wechat-mp

Weekly Downloads

3

Version

0.0.4

License

MIT

Unpacked Size

5.33 kB

Total Files

6

Last publish

Collaborators

  • axolo