npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

co-wx

v1.0.4

Published

WeChat server develop toolkit, with generator functions

Readme

co-wx

Yet another WeChat toolkit in generator style.

Installation

npm install --save co-wx

BodyParser

A connect style request body parser, checks signature of message and parses WeChat message body to req.body;

var WxParser = require('co-wx/parser');

app.all('/robot', WxParser('<signature-token>'), function (req, res, next) {
  var msgType = req.body['MsgType'];
  switch (msgType) {
    case 'event':
      var eventType = req.body['Event']; // => [ 'subscribe' | 'SCAN' | 'LOCATION' | 'CLICK' | 'VIEW' | 'unsubscribe' ]
      // ...
      return res.reply({
        MsgType: 'text',
        Content: 'No comment'
      });
    break;
    case 'text':
      // ...
    break;
  }
  return res.status(200).send(); // Stuffy sound made big money o-o
});

Use res.reply will reply a xml document described as official documentation. FromUserName and ToUserName in the reply object defaults to the value of ToUserName and FromUserName from the incoming message. And a CreateTime record will be generated automatically in the xml document.

Platform API

var WxAPIProvider = require('co-wx/api');

var wxApi = new WxAPIProvider({
  appId: '<your-app-id>',
  secret: '<and-the-secret>'
});

Retrieve information of specific subscriber

var co = require('co');

co(function* () {
  var subscriberInfo = yield wxApi.getSubscriberInfo('<open-id>');
  // => { openId, unionId, nickname, gender, photo, country, province, city, lang }
})
.then(function () { /* ... */ });

Use with a co-router

var Router = require('co-router');

var router = Router();

router.get('/user/:openId', function* (req, res, next) {
  return res.status(200).send(yield wxApi.getSubscriberInfo(req.params.openId));
});

app.use('/some-prefix', router);

Sending a service template message to subscriber

yield wxApi.sendTemplateMessageToSubscriber('<template-id>', openId, url, {
  /* template data */
});

Create a temporary scene based QRCode

var ticket = yield wxApi.createTemporaryQrCode(sceneId, expiresIn);

expiresIn parameter is optional and defaults to maximum value of 7 days. returns a ticket object contains QRCode ticket and url data.

JSSDK parameter API for wx.config (use co-router)

router.get('/config', function* (req, res, next) {
  return res.status(200).send(yield req.wx.getJsApiConfig(req.query.url || req.get('Referer')));
});

Debug

Start with DEBUG variable set to wx:* should turn on debug output of the module.

DEBUG=wx:* npm start

Roadmap

  • [x] Basic message handling
  • [ ] Support AES message security mode
  • [ ] Support customer service account interface
  • [x] Support service template message
  • [ ] Message broadcast
  • [ ] Media management
  • [ ] Menu management
  • [ ] Subscriber group/tag management
  • [x] Support OAuth 2.0
  • [x] Generate scene based QRCode
  • [x] Generate JS-SDK config
  • [ ] URL shortener
  • [ ] Statistics API
  • [ ] Koa-compatible middleware
  • [ ] ...

Contribution

The module is developed and used in some of my personal works. I may not implement a full set of APIs described in WeChat documentation. Feel free to open an issue for any feature request or contribution. I'll pick them up in my spare time :-)

License

(The MIT License)