egg-qcloud-weapp-sdk
v1.5.0
Published
egg的腾讯云微信小程序SDK插件
Downloads
5
Readme
egg-qcloud-weapp-sdk
Install
$ npm i egg-qcloud-weapp-sdk --save
Usage
// {app_root}/config/plugin.js
exports.qcloudWeappSDK = {
enable: true,
package: 'egg-qcloud-weapp-sdk',
};
Configuration
// {app_root}/config/config.default.js
exports.qcloudWeappSDK = {
serverHost: '',
authServerUrl: '',
tunnelServerUrl: '',
tunnelSignatureKey: '',
tunnelCheckSignature: true,
networkTimeout: 30000,
};
Why and What: wafer-node-server-sdk is for Express,but eggjs is based on Koa. so, you know.. This plugin comes out to solve the problem.
Note: Tunnel service is not supported now.
see config/config.default.js for more detail.
Example
// app/controller/weapp.js
module.exports = app => {
class WeappController extends app.Controller {
* login() {
const { ctx, app } = this;
const loginService = app.qcloudWeapp.LoginService.create(ctx.request, ctx.response);
yield loginService.login()
.then(data => {
ctx.body = data;
});
}
* user() {
const { ctx, app } = this;
const loginService = app.qcloudWeapp.LoginService.create(ctx.request, ctx.response);
yield loginService.check()
.then(data => {
ctx.body = {
code: 0,
message: 'ok',
data: {
userInfo: data.userInfo,
},
};
});
}
}
return WeappController;
};
Questions & Suggestions
Please open an issue here.