egg plugin for wechat-api
$ npm i egg-wechat-api --save
Node.js >= 7.x
- egg
- other
// {app_root}/config/plugin.js
exports.wechatApi = {
enable: true,
package: 'egg-wechat-api',
};
if redis is single client
// {app_root}/config/config.default.js
exports.wechatApi = {
appId: '',
appSecret: '',
};
if redis is multi clients
// {app_root}/config/config.default.js
exports.wechatApi = {
appId: '',
appSecret: '',
redisInstance: '', // select instance of redis
};
Redis is required !
see config/config.default.js for more detail.
'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;
}
});
};
Please open an issue here.