Skip to content

nealnote/koa-weixin-token

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Koa weixin-token

weixin-token for koa.

Install

npm install koa-weixin-token

API

const Koa = require('koa');
const app = new Koa();

app.use(require('koa-weixin-token')({
  appid: 'YOUR_WEIXIN_APPID',
  secret: 'YOUR_WEIXIN_SECRET'
}));

app.use(funciton* (){
  this.body = {
    token: this.weixinToken,
    jsapiTicket: this.weixinJsApiTicket
  };
});

this.weixinToken/weixinJsApiTicket

app.use(funciton* (){
  this.body = {
    token: this.weixinToken,
    jsapiTicket: this.weixinJsApiTicket
  };
});

without koa

const Weixin = require('koa-weixin-token/weixin');

var weixin = new Weixin({
  appid: 'YOUR_WEIXIN_APPID',
  secret: 'YOUR_WEIXIN_SECRET'
});

weixin.on('token', function(token, expire){
  console.log('token', token, expire, this.getToken());
}).on('ticket', function(token, expire){
  console.log('ticket', token, expire, this.getTicket());
});

About

weixin token services for koa

Resources

License

Stars

Watchers

Forks

Packages

No packages published