1.5.0 • Published 7 years ago

egg-qcloud-weapp-sdk v1.5.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

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

1.5.0

7 years ago

1.4.0

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago