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

mdc-weixin

v1.0.5

Published

Wechat adapter for MDC.

Readme

mdc-weixin

Message Distributing Center (MDC) 专用微信模板消息适配器。

安装

$ npm install --save mdc-weixin

or

$ yarn add  mdc-weixin

使用

配置

在 MDC 配置文件中做好配置,如:

{
  ...,
  "pubsub": {
    ...,
    "consumerAdapters": [{
      "queueName": "wechat",
      "require": "mdc-weixin",

      // 其它 mdc-wexin 参数
      ...
    }]
  }
}

其中其它 mdc-weixin 参数仅有一个 tokenUrl,代表获取该微信发送器所必须的 Access Token 获取的地址。

因为一个公众号同时只能拥有一个 Access Token,所以不能在该队列系统中维护,需要开发者自行在其主系统维护。而实际上这个 tokenUrl 就是 mdc-weixin 在需要 Access Token 的时候主动通过 GET 请求的一个地址,其返回 200 的状态码表示获取成功,输出内容直接为 Access Token 即可。

所以一个可能的参数是:

"consumerAdapters": [{
  "queueName": "wechat",
  "require": "mdc-weixin",

  "tokenUrl": "http://127.0.0.1/wechat/get-token"
}]

而通过 cURL 访问这个 tokenUrl 时,它的输出结果应该形如下方输出:

$ curl -v http://127.0.0.1/wechat/get-token

*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to foo.com (127.0.0.1) port 80 (#0)
> GET /wechat/get-token HTTP/1.1
> Host: foo.com
> User-Agent: curl/7.51.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Mon, 08 May 2017 09:48:32 GMT
< Content-Type: text/html; charset=utf-8
< Content-Length: 138
< Connection: keep-alive
<
* Curl_http_done: called premature == 0
* Connection #0 to host foo.com left intact
PuBvH2tdWU-eIe36MeQe8rWp-YkkMtimf3ijQ0nHAKSXFOASijCDVwfhPk05ef7qCG14h6spmM-arz7SZ11w-h_bCC518RuS9KrypFAMAHJnRxQtP4xDuk1q4_DKYn03EF9cACAYZX%

消息格式

在生产者端生产消息的时候,注意使用这样的消息格式:

发送客服消息

{
    "emit": "sendCustomer",
    "queue": "queue name",
    "message": {
        "touser": "openId",
        "msgtype": "msgtype",
        "text": {
            "content": "Hello World"
        }
    }
}

客服消息参考

发送模板消息

{
    "emit": "sendTemplate",
    "queue": "queue name",
    "message": {
        "templateId": "templateId",
        "to": "openId",
        "url": "url",
        "data": {
            "first": {
                "value": "value ",
                "color": "color"
            }
        }
    }
}

模板消息参考

贡献者 Contributors

死月 @XadillaX

老魏 @503945930