All Projects → seasonstar → egg-weapp-sdk

seasonstar / egg-weapp-sdk

Licence: MIT license
Egg的微信小程序登录会话管理SDK

Programming Languages

javascript
184084 projects - #8 most used programming language
Vim Script
2826 projects

Projects that are alternatives of or similar to egg-weapp-sdk

Egg 24time
A Twitter-like news and social server for Egg. 微信小程序社区全栈解决方案
Stars: ✭ 493 (+344.14%)
Mutual labels:  weapp, egg, egg-plugin
egg-session
session plugin for egg
Stars: ✭ 48 (-56.76%)
Mutual labels:  session, egg, egg-plugin
egg-session-redis
redis store for egg session
Stars: ✭ 41 (-63.06%)
Mutual labels:  session, egg, egg-plugin
egg-sentry
Sentry Plugin For Egg.js
Stars: ✭ 18 (-83.78%)
Mutual labels:  egg, egg-plugin
egg-aop
AOP plugin for eggjs, add DI, AOP support.
Stars: ✭ 44 (-60.36%)
Mutual labels:  egg, egg-plugin
Cool Admin Api
cool-admin-api 是基于egg.js、typeorm、jwt等封装的api开发脚手架、快速开发api接口
Stars: ✭ 188 (+69.37%)
Mutual labels:  egg, egg-plugin
Egg Socket.io
socket.io plugin for eggjs.
Stars: ✭ 209 (+88.29%)
Mutual labels:  egg, egg-plugin
Egg Validate
validate plugin for egg
Stars: ✭ 224 (+101.8%)
Mutual labels:  egg, egg-plugin
Egg Redis
redis plugin for egg
Stars: ✭ 234 (+110.81%)
Mutual labels:  egg, egg-plugin
egg-kafka-node
kafka plugin for egg.js
Stars: ✭ 36 (-67.57%)
Mutual labels:  egg, egg-plugin
Egg Oauth2 Server
🌟 OAuth2 server plugin for egg.js based on node-oauth2-server
Stars: ✭ 174 (+56.76%)
Mutual labels:  egg, egg-plugin
egg-rbac
Role Based Access Control for eggjs
Stars: ✭ 32 (-71.17%)
Mutual labels:  egg, egg-plugin
Egg Multipart
multipart plugin for egg
Stars: ✭ 145 (+30.63%)
Mutual labels:  egg, egg-plugin
Egg Security
Security plugin for egg, force performance too.
Stars: ✭ 204 (+83.78%)
Mutual labels:  egg, egg-plugin
Egg View Vue
vue view plugin for egg
Stars: ✭ 136 (+22.52%)
Mutual labels:  egg, egg-plugin
Egg Router Plus
The missing router feature for eggjs
Stars: ✭ 117 (+5.41%)
Mutual labels:  egg, egg-plugin
Egg Schedule
Schedule plugin for egg
Stars: ✭ 76 (-31.53%)
Mutual labels:  egg, egg-plugin
Egg Passport
passport plugin for egg
Stars: ✭ 98 (-11.71%)
Mutual labels:  egg, egg-plugin
Nideadmin
【未完成】NideAdmin - 基于 Vue.js + Egg.js 的微信小程序后台框架
Stars: ✭ 35 (-68.47%)
Mutual labels:  weapp, egg
egg-exporter
Egg.js 的 Prometheus 指标收集插件,附带 Grafana 看板。
Stars: ✭ 24 (-78.38%)
Mutual labels:  egg, egg-plugin

egg-weapp-sdk

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

可移步中文文档

Dependencies

Egg-weapp-sdk should be interacted with qcloud-weapp-client-sdk in Weapp Client

Demo

egg-24time

Server [Egg,Mysql,Redis, ES6]

weapp-24time

Weapp Client

Install

$ npm i egg-weapp-sdk --save

Usage

// {app_root}/config/plugin.js
exports.redis = {
  enable: true,
  package: 'egg-redis',
};

exports.weappSDK = {
  enable: true,
  package: 'egg-weapp-sdk',
};

Configuration

// {app_root}/config/config.default.js

module.exports = appInfo => {
  const config = {};

  config.redis = {
    client: {
      host: '127.0.0.1',
      port: '6379',
      password: '',
      db: '0',
    },
  };

  // replace your appId and appSecret of WEAPP
  config.weappSDK = {
    appId: 'xxxxxxxxxxx',
    appSecret: 'xxxxxxxxxxxxxxxxxx',
  };

  return config;
};
  • Why and What: Manage weapp user session independently, use Redis to store session.

see config/config.default.js for more detail.

  • Two methods:
  1. Login: loginService.login()

  2. Check: loginService.check()

Example

// app/controller/weapp.js
module.exports = app => {
  class WeappController extends app.Controller {
    * login() {
      const { ctx, app } = this;
      const loginService = app.weapp.LoginService.create(ctx.request, ctx.response);
      yield loginService.login()
        .then(data => {
          ctx.body = data;
        });
    }

    * user() {
      const { ctx, app } = this;
      const loginService = app.weapp.LoginService.create(ctx.request, ctx.response);
      yield loginService.check()
        .then(data => {
          ctx.body = {
            code: 0,
            message: 'ok',
            data: {
              userInfo: data.userInfo,
            },
          };
        });
    }
  }
  return WeappController;
};

Credits && Inspiration

腾讯云微信小程序客户端 SDK

Questions & Suggestions

Please open an issue here.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].