Skip to content

relzhong/egg-wechat-api

 
 

Repository files navigation

egg-wechat-api-cache

NPM version

egg plugin for wechat-api

Install

$ npm i egg-wechat-api-cache --save

use a inmemory cache see node-cache-manager for more cache engine

$ npm i cache-manager-memory-store --save 

Prerequisite

Node.js >= 8.x

Usage

Dependencies

Configuration

// {app_root}/config/plugin.js
exports.wechatApiCache = {
  enable: true,
  package: 'egg-wechat-api-cache',
};

use egg-cache default store

// {app_root}/config/config.default.js
exports.wechatApi = {  
  appId: '',
  appSecret: '',
};

select egg-cache store.

// {app_root}/config/config.default.js
exports.wechatApi = {
  appId: '',
  appSecret: '',
  cacheInstance: '', // select store of egg-cache
};

egg-cache is required !__

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

Example

'use strict';

module.exports = app => {

  app.get('/', function* () {

    const { wechatApi } = app;

    try {
      const ticket = yield wechatApi.getTicket();
      this.status = 200;
      this.body = ticket;

    } catch (error) {
      this.status = 500;
      this.body = error;
    }
  });

};

Questions & Suggestions

Please open an issue here.

License

MIT

About

Wechat Api for Egg.js

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 63.5%
  • Shell 36.5%