1.2.1 • Published 6 years ago

egg-wechat-api-cache v1.2.1

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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

1.2.1

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago