Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nealnote/koa-weixin-token

weixin token services for koa
https://github.com/nealnote/koa-weixin-token

Last synced: 26 days ago
JSON representation

weixin token services for koa

Awesome Lists containing this project

README

        

# Koa weixin-token

weixin-token for koa.

## Install

```
npm install koa-weixin-token
```

## API

```js
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

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

### without koa
```js
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());
});
```