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

ift

v1.0.0

Published

InterFace Toolkit

Downloads

9

Readme

ift

InterFace Toolkit 接口工具集

by 鬼道(luics

安装

tnpm install -g ift

MAC 用户请使用sudo tnpm install -g ift

1. 初始化

请使用 ift -h 查看所有命令

请在项目根目录下运行

ift -i

or

ift --init

会影响的文件结构为

demo/
--data/
----demo.js
----if-config.json
doc/

数据文件

ift -i 生成的 demo.js 是一个 IF 数据文件,即可以作为调试数据使用(ift -e),又能生成接口文档(ift -s)。 下面显示了重要的配置信息:

exports.config = {
    "name": "这是接口名",
    "desc": "这是接口的详细描述",
    // 线上地址
    "url": "http://example.com/demo",
    // 日常地址
    "urlDaily": "http://daily.example.net/demo",
    // 预发地址
    "urlPrepub": "http://example.com/demo",
    // 支持的 Method 集合
    "method": ['GET', 'POST'],
    // 响应与模板的映射关系
    "template":{
        "response": "tpl1.php",
        "responseError": "tpl2.php"
    }
};

2. 文档同步

用于将数据文件 demo.js 生成接口文档

请在项目根目录下运行(首次运行该命令前请先运行ift --init

ift -s

or

ift --sync

该命令默认读取的配置文件位于 demo/data/if-config.json,所有数据文件均位于 demo/data/

默认生成的接口文档为 doc/api.md(查看 api.md 文档

doc/
--api.md

if-config.json

if-config.json 是接口文档配置文件

{
    "title": "接口文档",
    "extraHtml": "<h3>额外的html片段</h3>",
    "savePath": "../../doc/api.md",
    "files": [
        "demo"
    ]
}
  1. savePath 设置保存接口文档的相对路径
  2. files 指定接口文件,无需文件扩展名

3. 接口服务器

请在项目根目录下运行

ift -e -p 9999

or

ift --server --port 9999

浏览器中访问 http://localhost:9999/demo.jsdemo.js 可替换为合适的值

4. 接口校验

  1. 运行于 node 环境
    • 调用

      require('ift').ifCheck({data-format:1}, {data:1});
    • 返回

      {
        "pass": 1, // 1-校验通过 0-未通过
        "defined": 4, // 校验的字段数
        "undefined": 0, // 需要定义却未定义的字段数
        "mismatch": 0, // 格式不匹配的字段数
        "stack": [ // 校验堆栈,一般用不着
            "{root}"
        ],
        "log": [] // 出错日志
      }
  2. 运行于 browser 环境
    • 调用

      window.ifCheck({data-format:1}, {data:1});
    • 返回 同 node 版本

  3. HTTP API,方便集成
    • http://if.alibaba-inc.com/check 支持 POST/GET
    • 文档见 http://gitlab.alibaba-inc.com/x/ifcheck/blob/master/demo/api.md
    • Demo(HTTP GET)
  4. UI 工具