egg-wechat-api-cache

1.2.1 • Public • Published

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

Package Sidebar

Install

npm i egg-wechat-api-cache

Weekly Downloads

0

Version

1.2.1

License

MIT

Unpacked Size

6.85 kB

Total Files

8

Last publish

Collaborators

  • relzhong