Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/nealnote/koa-weixin-token
- Owner: nealnote
- License: mit
- Created: 2015-11-17T05:11:51.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-20T07:34:36.000Z (about 9 years ago)
- Last Synced: 2024-11-11T01:42:36.768Z (about 1 month ago)
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 10
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-koa - koa-weixin-token - 微信Token服务。 ![](https://img.shields.io/github/stars/nealnote/koa-weixin-token.svg?style=social&label=Star) ![](https://img.shields.io/npm/dm/koa-weixin-token.svg?style=flat-square) (仓库 / 中间件)
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());
});
```