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 🙏

© 2024 – Pkg Stats / Ryan Hefner

awesome-wechat-sdk

v2.9.1

Published

an awesome sdk for wechat oauth, api and message middleware

Downloads

33

Readme

awesome-wechat-sdk

Features

  • WechatApi - Library to call wechat backend
  • middleware - Koa middleware to process user message and event notification
  • WechatPay - Library to call wxpay api backend

Document

Class: WechatApi

new WechatApi(appid, appsecret)

  • appid <string> Wechat appid.
  • appsecret <string> Wechat appsecret.

Create an instance of WechatApi.

api.setEndpoint(domain)

  • domain <string> Alternative wechat endpoint domain.

Set endpoint to alternative access point. Available value can be api.weixin.qq.com|sh.api.weixin.qq.com|sz.api.weixin.qq.com|hk.api.weixin.qq.com.

api.setOpts(opts)

  • opts <UrlLibOptions> Options for urllib request.

Set default options for urllib request.

api.registerAccessTokenHandler(handler)

  • handler <object>
    • handler.loadAccessToken <Function> The handler for load access token, should return a promise which resolved with an instance of AccessToken.
    • handler.saveAccessToken <Function> The handler for save access token, accept an instance of AccessToken as parameter, should return a promise which resolved with void.

Register custom handler to handle access token. It is useful for a distributed application.

api.registerAuthAccessTokenHandler(handler)

  • handler <object>
    • handler.loadAuthAccessToken <Function> The handler for load auth access token, should return a promise which resolved with an instance of AuthAccessToken.
    • handler.saveAuthAccessToken <Function> The handler for save auth access token, accept an instance of AuthAccessToken as parameter, should return a promise which resolved with void.

Register custom handler to handle auth access token. It is useful for a distributed application.

api.getAuthorizeURL(redirect[, state[, scope]])

  • redirect <string> The target redirect uri. It's domain should match the config at wechat admin panel.
  • state <string> The reserved state value which will be send back unchanged at redirect page. Default value is an empty string.
  • scope <string> The auth scope. Available values are snsapi_base or snsapi_userinfo. Default value is snsapi_base
  • Returns: <string>

Get the well-formatted url for oauth.

api.getAuthUser(openid[, lang])

  • openid <string>
  • lang <string>
  • Returns: <Promise>

api.getAuthUserByCode(code[, lang])

  • code <string>
  • lang <string>
  • Returns: <Promise>

Class: AccessToken

new AccessToken(token)

  • token <object>
    • token.accessToken <string> The value of access token.
    • token.expireTime <number> The expire timestamp of access token.

token.isValid()

  • Returns: <boolean>

Determine whether the token is valid or not.

token.toJSON()

  • Returns: <object>

Valid for JSON stringify.

Class: AuthAccessToken

new AuthAccessToken(token)

  • token <object>
    • token.accessToken <string> The value of auth access token.
    • token.expireTime <number> The expire timestamp of auth access token.
    • token.refreshToken <string> The value of auth refresh token.
    • token.openid <string> The openid of user.
    • token.scope <string> The scope of auth access token.

token.isValid()

  • Returns: <boolean>

token.toJSON()

  • Returns: <object>