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

weixin-utils

v1.0.2

Published

WeChat development tools module.

Downloads

7

Readme

weixin-utils

npm downloads javascript style guide

WeChat development tools module.

工具库内部会对获取到的 access_tokenjsapi_ticket 进行缓存(若配置了redis则缓存到Redis中,反之则缓存到内存中),过期将自动刷新,工作流程图如下所示:

Flow Chart

Install

npm install weixin-utils

Usage

const utils = require('weixin-utils');
// 注册配置
utils.config({
  redis: 'redis://localhost:6379',
  apps: {
    myApp: {
      appid: 'xxx',
      secret: 'xxx',
      tokenKey: 'access_token',
      ticketKey: 'tools_ticket'
    }
  }
});
// 调用API
utils.access_token('myApp').then(access_token => console.log(access_token));

API

utils.config(opts)

配置注册函数,接收一个Object类型的配置对象,对象结构参考以上示例,其中redis非必填参数,当redis为空时采用内存模式,即每次应用重启则清空缓存信息。

utils.access_token(appKey)

获取access_token,需要传入一个appKeyappKey即为配置对象中的apps部分的key),返回一个Promise对象,该函数内部会自动检测是否存在缓存的令牌(默认在每次获取令牌后)。

utils.jsapi_ticket(appKey)

获取jsapi_ticket,同样需要传入一个appKey,返回值也为一个Promise对象。

utils.signature(obj)

获取参数签名,传入一个querystring的参数对象,返回值为签名数据。