Skip to content

Commit

Permalink
实例添加方法,添加__tests__
Browse files Browse the repository at this point in the history
  • Loading branch information
Changlon committed Jan 24, 2022
1 parent bc66b80 commit 978222b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 82 deletions.
15 changes: 0 additions & 15 deletions example/common.ts

This file was deleted.

39 changes: 39 additions & 0 deletions example/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

import koa from 'koa'
import koaRouter from 'koa-router'
import koaXmlBody from 'koa-xml-body'
import WechatApplication from "../src/lib/wechat"

const weapp = new WechatApplication({
appId:"wx3ace0c0fa2f4cab0",
appSecret:"8ea32e13460637765fb65a5e48b7c023",
token:"changlon"
})

var OPENID
weapp.text("debug",async acc =>{
OPENID = acc.fromUser
acc.send.sendTxtMsg("debuging...")
})

const Service = new koa()
const Router = new koaRouter()


Router.all(`/wechat_debug`,weapp.start())
Router.all(`/debug`,async (ctx,next)=>{
const debugFuncName = ctx.query.func || "pushTxtCustomerMsg"
const openid = ctx.query.openid
const content = ctx.query.content
console.log(debugFuncName,openid,content)
const debugTarget = weapp[`${debugFuncName}`]
const res = await debugTarget(openid,content)
console.log(res)
})


Service.use(koaXmlBody())
Service.use(Router.routes())
Service.listen(3001)


23 changes: 0 additions & 23 deletions example/oauth.ts

This file was deleted.

44 changes: 0 additions & 44 deletions example/send.ts

This file was deleted.

0 comments on commit 978222b

Please sign in to comment.