Skip to content

seasonstar/egg-qcloud-weapp-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

egg-qcloud-weapp-sdk

NPM version build status Test coverage David deps Known Vulnerabilities npm download

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.

License

MIT

About

eggjs的基于wafer的腾讯云微信小程序SDK插件

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published