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

koa-weixiao-controller

v1.2.1

Published

koa: 腾讯微校第三方应用快速开发路由

Readme

koa-weixiao-controller

koa: 腾讯微校第三方应用快速开发路由。

本路由将请求签名验证、时间戳验证、微校json数据解析、微信xml数据解析等操作进行了封装。

如何使用

安装

yarn add koa-weixiao-controller

npm install koa-weixiao-controller -S

注意事项

  1. 必须使用了 koa-json 插件。
  2. 如果你同时使用了 koa-bodyparser 插件,请参照以下修改你的代码:
const Koa = require('koa');
const bodyParser = require('koa-bodyparser');
const weixiaoController = require('koa-weixiao-controller');

app.use(weixiaoController.compatibleWithBodyParser('/weixiao'/* 应用路径 */));
app.use(bodyParser());

// ........

使用

weixiao.controller.js

const weixiaoController = require('koa-weixiao-controller');
module.exports = weixiaoController({
  api: {
    key: 'your key',
    secret: 'your secret',
    token: 'your token' // 仅 `消息回复类` 应用需要
  },
  hooks: {
    async open(ctx, { mediaId, Weixiao }) {
      // 应用开启

      // 在这里执行一些应用开启相关操作

      ctx.body = Weixiao.generateResponse({
        token: 'hello',
        is_config: 1
      });
    },
    async trigger(ctx, { body, mediaId }) {
      // 应用触发

      // 如果是消息回复类应用
      ctx.body = `<xml><ToUserName><![CDATA[${body.FromUserName}]]></ToUserName>.............</xml>`;

      // 如果是网页应用
      ctx.redirect('http://baidu.com'/* 应用的网页地址 */);
    },
    async keyword(ctx, { body, mediaId }) {
      // 关键词更新

      // 一些操作, 如: db.table('apps').where({ mediaId }).update({ keywords: body.keyword });
    },
    async config(ctx, { mediaId }) {
      // 打开配置页面

      // 一些操作, 如: ctx.render('config', { mediaId });
    },
    async monitor(ctx, { mediaId }) {
      // 应用监控

      // 执行一些操作, 默认会执行操作: ctx.body = ctx.query.echostr;
    }
  }
});

index.js

// .....

const router = require('koa-router')();
const weixiaoController = require('./controllers/weixiao.controller.js');

router.all('/weixiao', weixiaoController);

// .....