wechat-router
wechat-router是一个基于node-wechat的微信路由中间件,用法类似express的router
Installation
$ npm install wechat-router
Use with Connect/Express
const wechat = require('wechat');
const Router = require('wechat-router');
const config = {
token: 'token',
appid: 'appid',
encodingAESKey: 'encodinAESKey'
};
let router = new Router();
router.text('hello', (req, res, next)=> {
res.reply('word');
});
let anotherRouter = new Router();
anotherRouter.event({EventKey: '123456'}, (req, res, next)=> {
res.reply({
type: "music",
content: {
title: "来段音乐吧",
description: "一无所有",
musicUrl: "http://mp3.com/xx.mp3",
hqMusicUrl: "http://mp3.com/xx.mp3",
thumbMediaId: "thisThumbMediaId"
}
})
});
function midDeal(req, res, next) {
next();
}
router.event({Event: 'SCAN'}, midDeal, anotherRouter);
app.use(express.query());
app.use('/wechat', wechat(config, router));
##TODO
License
The MIT license.