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

wechat-es

v0.0.12

Published

基于ES 6及Fetch API实现的微信公众号平台开发API

Downloads

21

Readme

wechat-es

In Progress,Do Not Use It!

本项目起源于搭建微信公众号服务器

安装

npm i -S wechat-es

功能构成

跟微信公众号开放的API相对应,库主要提供两个服务类,分别是WaiterTalker,可以在测试中看到这两个类的主要用法。

Waiter

Waiter负责接收公众号的消息,进行签名的验证,还可以将响应封装成XML。

下面这个例子需要用到express和xmlparser:

npm i -S express
npm i -S express-xml-bodyparser

然后创建App,定义路由处理请求:

const app = express()
//Initialize an instance of Weixin
const weixin = new Weixin({
	appId: 'YourAppId',
	appSecret: 'YourAppSecret',
	token: 'Token'
})
const waiterUrl = '/api/weixin'

app.use(express.query())
/**
* Process verify signature request with get method
*/
app.get(waiterUrl, function (req, res, next) {
  const waiter = weixin.getWaiter()
  const {
		signature,timestamp,nonce
	} = req.query

	if(waiter.verifySignature(signature,timestamp,nonce)) {
		res.send(req.query.echostr)
	} else {
		res.send('error')
	}
});
/**
* Process other requests with post method
* We use xmlparser to convert xml in request body to json
*/
app.post(waiterUrl,xmlparser({trim: true, explicitArray: false}),function (req, res, next) {
  const waiter = weixin.getWaiter()
  /**
  * Your need provide a populateReply method for waiter to
  * response what you want.The default implement just reply
  * an text message to say 'I received your message'
  */
  //waiter.populateReply = function(message) {}

  const reply = waiter.process(req)
  res.set('Content-Type', 'text/xml')
  res.send(reply)
});

Talker

Talker 负责给微信公众号服务器发送消息,可以在任何地方使用,用manager创建消息,然后send这个消息就可以了。

const talker = weixin.getTalker()
talker.send(UserManager.getList())
		  .then(result => {
		  	if(!result.errcode) {		  		
				  console.log("Get users:",json)
		  		return CustomerMessageManager.text(result.next_openid,"感谢订阅")
		  	} else {
		  		console.log("Get user list got error:",result.errmsg)
				throw Error(result.errmsg)
		  	}
		  })
		  .then(message => talker.send(message))
		  .catch(error => {
		  	console.log("There is an error to get nextOpenId")
		  })
		  .then(result => {
			  	if(result.errcode) {		  		
					console.log(`Send text message to customer ${nextOpenId} got error:${result.errmsg}`)
			  	} else {
			  		console.log(`Send text message to ${nextOpenId} success`)		  		
			  	}
		   })

开发者参考