Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @dengzhaofun/egg-wechat-all with all npm packages installed. Try it out:

@dengzhaofun/egg-wechat-all lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("@dengzhaofun/egg-wechat-all/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@dengzhaofun/egg-wechat-all v0.1.4

wechat support for egg


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


$ npm i egg-wechat-all --save


// {app_root}/config/plugin.js
exports.wechatAll = {
  enable: true,
  package: 'egg-wechat-all',

egg-redis is required.


// {app_root}/config/config.default.js
exports.wechatAll = {
  appid: '',
  appsecret: '',
  token: '',
  encodingAESKey: '',
  payment: {
    partnerKey: '',
    mchId: '',
    notifyUrl: '',
    pfx: '',
  modules: {
    message: true,  // enable or disable co-wechat
    api: true,  // enable or disable co-wechat-api
    oauth: true,  // enable or disable co-wechat-oauth
    payment: true,  // enable or disable co-wechat-payment

see config/config.default.js for more details.


app.wechat.messageMiddleware //co-wechat middleware
app.wechat.api  // co-wechat-api
app.wechat.oauth  // co-wechat-oauth
app.wechat.payment  // co-wechat-payment

For more details, please refer to the following links.

[co-wechat] (

[co-wechat-api] (

[co-wechat-oauth] (

[co-wechat-payment] (


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

module.exports = app => {
  class WechatController extends Controller {
    async oauth() {
      const token = await app.wechat.oauth.getAccessToken(this.ctx.query.code);
      this.ctx.body = JSON.stringify({
        query: this.ctx.query,
        user: await app.wechat.api.getUser(,
      }, 2, 2);

  WechatController.prototype.index = app.wechat.messageMiddleware(async (message, ctx) => {, [{
      title: 'OAuth test',
      description: 'Please tap this message to start oauth test',
      url: app.wechat.oauth.getAuthorizeURL('[URL(Route to WechatController.oauth)]', 'MY_STATE', 'snsapi_userinfo'),
      picurl: '[PIC_URL]',
    return `Received your message: ${message.Content}`;

  return WechatController;

Questions & Suggestions

Please open an issue here.



RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free