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

luban-server-sdk

v1.0.7

Published

> 把鲁班云函数用到的方法封装成组件,方便调用

Readme

luban-server-sdk

把鲁班云函数用到的方法封装成组件,方便调用

use

install

npm i -S luban-server-sdk

require and use

const Luban = require('luban-server-sdk')
const lb = new Luban({
  sysdb: {
    host: '',
    port: '',
    username: '',
    password: '',
    database: ''
  },
  conns: [{
    name: '',
    host: '',
    port: '',
    username: '',
    password: '',
    database: ''
  }],
  redis: {
    host: '',
    port: 6379,
    password: ''
  },
  lubanConfig: {
    // 公众号
    mpAppId: '',
    mpAppSecret: '',
    // 微信小程序
    wxAppId: '',
    wxAppSecret: '',
    // qq小程序
    qqAppId: '',
    qqAppSecret: ''
  },
  qcloud: {
    appId: '',
    secretId: '',
    secretKey: ''
  },
  cos: {}
})

instance api

utils

resp

构造腾讯云函数的返回体

return lb.utils.resp(data, statusCode, headers, isBase64Encoded)

|参数名|类型|默认值|说明| |:-----|:-----|:-----|:-----| |data|Any|null|返回给请求方的数据| |statusCode|Number|200|状态码| |headers|Object|{}|返回头| |isBase64Encoded|Boolean|false|是否base64编码(例如要返回图片,data就是图片的base64编码字符串,isBase64Encoded要设置为true)|

getSessionInfo

获取session信息

getAccessToken

获取access_token(公众号、小程序)

getSignInfo

获取js签名信息(公众号)

let sessionInfo = await lb.utils.getSessionInfo(lubanAppId, lubanSessionKey)
let accessToken = await lb.utils.getAccessToken(lubanAppId, platform)
let signInfo = await lb.utils.getSignInfo(lubanAppId, weburl)

|参数名|类型|默认值|说明| |:-----|:-----|:-----|:-----| |lubanAppId|String||鲁班AppId| |lubanSessionKey|String||鲁班SessionKey| |platform|String|wx|wx=微信小程序,mp=微信公众号,qq=qq小程序| |weburl|String||要获取签名的网页url|

login

服务端统一登录接口

let loginInfo = await lb.login(data, lubanAppId, platform)

|参数名|类型|默认值|说明| |:-----|:-----|:-----|:-----| |data|Object||登录所需的数据| |lubanAppId|String||鲁班AppId| |platform|String|wx|wx=微信小程序,mp=微信公众号,qq=qq小程序|

handleUserInfo

服务端统一处理用户信息接口(小程序)

let userInfo = await lb.handleUserInfo({
  encryptedData,
  iv,
  lubanAppId,
  lubanSessionKey,
  platform
})

|参数名|类型|默认值|说明| |:-----|:-----|:-----|:-----| |encryptedData|String||用户信息加密串| |iv|String||加密向量| |lubanAppId|String||鲁班AppId| |lubanSessionKey|String||用户sessionkey| |platform|String|wx|wx=微信小程序,qq=qq小程序|

db

// 1. 引用一个knex实例,其中aa是config中的连接名
let data = await lb.db.aa('table_name').select()

// 2. sys是一个固定连接名,用来获取系统db连接实例
// 例子:根据appid获取app信息
let app = (await lb.db.sys('app').where('appid', event.queryString.appid))[0]

cache

get

通过一个key获取缓存数据

let data = await lb.cache.get('KEY')

set

写入缓存

await lb.cache.set('KEY', 'VALUE')

setEx

写入定时过期缓存

await lb.cache.setEx('KEY', 'VALUE', 30) // 30秒自动过期

cos

腾讯云对象存储操作

upload