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 🙏

© 2025 – Pkg Stats / Ryan Hefner

node-api-connector

v1.1.7

Published

node-api-connector

Readme

node-api-connector

usage

  1. 安装

     npm install node-api-connector
  2. 添加到 express

     var g = new guard({
         PACKAGE_HOME: __dirname + '/package',
         /* api 配置 */
         api: {
             use: function(appid, callback) {
                 callback(null, {
                     'store': true,
                     'wx_conf': true,
                     'wx_oauth': true,
                     'wx_pay': true
                 });
             },
    
             conf: {
                 get: function(appid, config, callback) {
                     for(var key in config){
                         if(key == 'appid'){
                              config['appid'] = 'wx50d746e9d0f0af1d';//'wx22fb445469f289a2';
                         }
                     }
                     callback(null, config);
                 }
             },
    
             data: {
                 save: function(appid, apiname, data,callback){
                     console.log('==== data ====');
                     console.log(appid + ':' + apiname);
                     console.log(data);
                     callback(null,null);
                 }
             },
    
             called: function(appid,apiname,ip,refer){
                 //TODO
             }
         },
    
         /* 保存API返回数据*/
         data: function(appid,apiname,data,callback){
             callback(null);
         }
     });
     app.use(g.proxy);
    	
    	

    opt 说明:

    • PACKAGE_HOME: 放置 package 的根目录;
    • api.use: 根据 appid 获取 enabled 的 api
    • get_conf: 获取通用设置

endpoints

  • 前端页面的 js 库

    endpoint: /mkit.js
    method: GET
    验证: none
    参数:
    none 说明:
    前端 js 类库
    测试:
    http://localhost:8000/mkit.js

  • 前端 js库加载的函数库

    endpoint: /{appid}/fn.js
    method: GET
    验证: none
    参数:
    appid: appid, 必填
    说明:
    前端 api.js 加载完成之后会加载此文件, 在添 mkit 中添加指定app的前端接口
    测试:
    http://localhost:8000/foo/fn.js

  • 前端页面函数库掉用的接口地址

    endpoint: /{appid}/endpoint/{wx_conf}
    method: GET
    验证: none
    参数: appid: appid, 必填
    说明:
    不同 API 接口被前端调用的中间地址, 服务器根据此地址转发到真正的
    地址 (manifest.json 文件中)上
    测试:
    http://localhost:8000/foo/endpoint/wx_conf

  • 获取所有已公开的API列表

    endpoint: /api/list
    验证: none
    参数:
    none
    说明:
    获取所有已公开的API列表
    测试:
    http://localhost:8000/api/list

  • 获取某个 API 详情

    endpoint: /api/{apiname}
    验证: none
    参数:
    apiname: api name, 必填
    说明:
    获取某个API详情, 包括标题, 描述, 及配置信息等, 但不包含 doc
    测试:
    http://localhost:8000/api/wechat_conf

  • 获取某个 API markdown doc

    endpoint: /api/{apiname}/doc
    验证: none
    参数:
    apiname: api name, 必填
    说明:
    获取某个 API markdown content
    测试:
    http://localhost:8000/api/wechat_conf/doc

  • 获取某个 API 配置

    endpoint: /{uid}/{appid}/{apiname}/conf 方法: GET 验证: none
    参数:
    uid: 必填
    appid: 必填
    apiname: 必填
    说明:
    获取某个 API 配置
    测试:
    http://localhost:8000/uid/appid/store/conf

  • 更新某个 API 配置

    endpoint: /{uid}/{appid}/{apiname}/conf 方法: POST 验证: none
    参数:
    uid: 必填
    appid: 必填
    apiname: 必填
    说明:
    更新配置到 API, 通过form key value提交, key 的约定形式见文档;