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

tbrequest

v1.0.10

Published

a request packages

Readme

tbrequest

var app = getApp()
let path = ''

/*
  属性:
    userAgentTb:UA
    formatDateUTC:服务器时间戳
    authorization: 接口需要的验签
    domain: 接口的域名
    showToast: toast提示
    report_noaction: mattermost 通知
    report_default: mattermost 通知
    fName: 框架名称
    fType: 框架类型 // wx(企业微信) Feishu(飞书)
    miniprogramName: 小程序名称 用户判断 用户id key值
*/

function reqObject(argument){
  this.userAgentTb = argument.userAgentTb;
  this.formatDateUTC = argument.formatDateUTC;
  this.authorization = argument.authorization;
  this.domain = argument.domain;
  this.showToast = argument.showToast;
  this.report_noaction = argument.report_noaction;
  this.report_default =  argument.report_default;
  this.fName = argument.fName;
  this.fType = argument.fType;
  this.miniprogramName = argument.miniprogramName


  //判断domain + url 的函数
  this.request = (data)=>{
    // console.log("data:",data)
    return new Promise((re, rj) => {
      if (data.apiType == "api") {
        path = this.domain.api 
      }
      if (data.apiType == "mp") {
        path = this.domain.mp
      }
      data.path = path;
      console.log('data:', data);
      if (data.data.requestType == "login" || data.data.requestType == "reportNoaction" || data.data.requestType == "reportDefault" || data.data.requestType == "bindPhone" || data.data.requestType == "passCode") {
        this.publicRequest(data).then(
          res => {
            re(res)
          },
          err => {
            rj(err)
          })
      } else {
        if (!getApp().globalData.uc_uid) {
          if(this.fType=='Feishu') return false
          getApp().userLogin('', 'page').then((res) => {
            if(this.miniprogramName=='com.bianxingjimu.FA'){
              data.data.fa_user_id = getApp().globalData.uc_uid;
            }else{
              data.data.uc_uid = getApp().globalData.uc_uid;
            }
            this.publicRequest(data).then(
              res => {
                re(res)
              },
              err => {
                rj(err)
              })
          }, (err) => {
            if (err.errMsg == "request:fail timeout") {
              showToast({
                msg: '网络出现故障,请稍后重试'
              })
            } else {
              console.log("err", err)
            }
            rj('fail')
          })
        } else {
          this.publicRequest(data).then(
            res => {
              re(res)
            },
            err => {
              rj(err)
            })
        }
      }
    })
  }
  //公共的函数
  this.publicRequest = data=> {
    return new Promise((re, rj) => {
      let userAgentTb =this.userAgentTb
      let _date = this.formatDateUTC();
      let contentType = 'application/json; charset=UTF-8';
      let header={
        'content-type': contentType,
          'user-agent-tb': userAgentTb,
          'X-Tb-Date': _date,
          'Date': _date,
          'Authorization': this.authorization(_date, data.url, contentType)
      } 
      this.fName.request({
        url: data.path + data.url,
        data: data.data,
        header,
        method: data.method,
        dataType: 'json',
        responseType: 'text',
        success: (res) => {
          if (res.statusCode == 200) {
            re(res.data)
          } else {
            data.source = 'mini_program'
            data.getUid = true;
  
            if (data.data.count == 2) {
              return;
            }
            this.reportNoaction({
              page: 'http Error ',
              url: data.url,
              code: res.statusCode,
              input_params: data,
              type: 'reportNoaction',
              source: 'mini_program',
              count: 2
            })
          }
        },
        fail: (res) => {
          if (res.errMsg == "request:fail timeout") {
            showToast({
              msg: '网络出现故障,请稍后重试'
            })
          } else {
            console.log("res", res)
          }
  
          rj(res)
        },
        complete() {
  
        }
      })
    })
  }

}


module.exports = {
  reqObject
}