strapi-middleware-wxopen
TypeScript icon, indicating that this package has built-in type declarations

0.1.17 • Public • Published

Usage

koa

import Koa from "koa";
import wxComponentService from "wx-component-service";

const app = new Koa();

wxComponentService(
  app,
  // weixin component config
  {
    componentAppSecret: "****",
    componentAppId: "****",
    token: "****",
    encodingAESKey: "****",
  },
  // redis config
  {
    host: "your_redis_host",
    port: 6379,
    db: 20,
    password: "****",
  }
);

// registe route for revicing component_ticket
import KoaRouter from "koa-router";
const router = new KoaRouter();
router.post("/notify", async (ctx, next) => {
  const wxc = ctx.wxc;
  const ticket = await wxc.decodeTicket(ctx.request.xml);
  console.log(ticket);
  ctx.body = "success";
});

app.use(router.routes());

app.listen(8008);

Readme

Keywords

none

Package Sidebar

Install

npm i strapi-middleware-wxopen

Weekly Downloads

1

Version

0.1.17

License

MIT

Unpacked Size

65.4 kB

Total Files

34

Last publish

Collaborators

  • fs2hero