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

krpc-mini

v1.0.0

Published

KRPC client for weChat miniprogram, use wx.request(text base64) or cloud function

Readme

支持小程序调用rpc,使用wx.request

  1. 加入依赖
{
    "dependencies": {
        "krpc-mini":"~1.0.0"
    }
}
  1. 进入小程序目录构建
cd $miniprogram
yarn install
IDE : Tools -> Build npm
  1. 使用
// pages/index/index.ts
import {RpcResult,ServiceConfig,RpcService} from "krpc-base"
// 云函数版本
// import {CloudRpcClient as  RpcClient} from "krpc-mini"
import {RpcClient} from "krpc-mini"


var name = "hello wx!";
var rpcService : RpcService = RpcClient.create({
    host: "https://idemo.krpc.com",
    app: "demo-java-server",
    clientId: "m-youruuinon-id",
    //accessToken: "" 可选,需要登录的接口
})

rpcService.async("Demo/hello",{"name":name,"age":123})
    .then(res => {
        console.log(res)
    })

变更记录

1.0.1

  • 增加ServiceConfig.tokenProvider闭包,动态header处理,每次发请求会调用这个方法

tips

小程序不支持二进制请求

本质利用base64对protobuf信息进行文本化。wx.request要求字符串数据传输。

# 也可利用curl直接模拟grpc-web-text传输
curl 'https://example.krpc.com/demo-java-server/M/h' \
    -H 'accept: application/grpc-web-text' \
    -H 'c-id: m-youruuinon-id' \
    -H 'content-type: application/grpc-web-text' \
    --data-binary 'AAAAAAISAA=='

https://developers.weixin.qq.com/miniprogram/dev/api/network/request/wx.request.html#data-%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E

wx.request({
  url: 'https://course.krpc.com/course/M/v', 
  method:'POST',
  responseType:'arraybuffer',
  enableHttp2:true,
  data: [0,0,0,0,2,0x12,0x00],
  header: {
    'content-type': 'application/grpc-web+proto',
    'x-grpc-web':'1'
  },
  success (res) {
    console.log(res.data)
  }
})
// 503 会强制json序列化, grpc-status: 14
//grpc-message: upstream connect error or disconnect/reset before headers. reset reason: remote reset

//只支持文本请求
wx.request({
  url: 'https://course.krpc.com/course/M/v', 
  method:'POST',
  enableHttp2:true,
  data: 'AAAAAAISAA==',
  timeout: 150,
  header: {
    'content-type': 'application/grpc-web-text',
    'x-grpc-web':'1'
  },
  success (res) {
    console.log(res.data)
  }
})

发布小程序

https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html

cd miniprogram
tsc

miniprogram-ci upload   --pp .  --pkp $PKP --appid $APPID \
  --uv 1.0.0.dev \
  -r 1 \
  --enable-es6 true \
  --enable-minify true \
  --enable-autoprefixwxss true


miniprogram-ci pack-npm --pp .  --pkp $PKP --appid $APPID 


#preview
miniprogram-ci  preview  --pp .  --pkp $PKP --appid $APPID \
  --uv 1.0.0.pre -r 1 \
  --enable-es6 true