Socket
Book a DemoInstallSign in
Socket

wechat-router

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wechat-router

wechat-router ============= wechat-router是一个基于[node-wechat](https://github.com/node-webot/wechat)的微信路由中间件,用法类似express的router ## Installation

0.0.1
latest
npmnpm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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) {
  //do something
  next();
}

router.event({Event: 'SCAN'}, midDeal, anotherRouter);

app.use(express.query());
app.use('/wechat', wechat(config, router));

##TODO

  • 对话模式
  • Koa/Co版

License

The MIT license.

FAQs

Package last updated on 21 Feb 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.