egg-wechat-api-cache
v1.2.1
Published
wechat-api for egg using egg-cache backend
Downloads
6
Readme
egg-wechat-api-cache
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
- egg
- other
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.