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

doclever-node-plugin-xin

v1.1.1

Published

【优信前端】从DOCLever系统获取接口mock 数据

Downloads

7

Readme

docLever-node-plugin

nodejs plugin for docLever

安装

npm install doclever-node-plugin-xin --save

使用

let doclevernode = require('doclever-node-plugin-xin');

doclevernode.queryDocLeverModel({
        host: 'apidev.xin.com', // 主机域名,默认请参见config
        port: '', // 端口,默认请参见config
        projectId: ObjectId(id), // 项目ID,默认请参见config
    }, function() {
        return {a: 1, b: 2}
    }
});

该接口以分组的形式返回该项目的接口数据,具体形式如下

{ 
    data: [
        {
            _id: "5acb085a597a3880e805b76c", // 组ID
            group_name: ["车型车系"], // 组名
            param: [ // 该组下的所有接口
                {
                    id: "7d6f2b30-3bbf-11e8-804a-f56ffc07bfc8", // 接口id
                    name: "车系列表", // 接口名称
                    url: "/series", // 接口路径
                    remark: "获取车系列表数据", // 接口描述
                    resultType: 0, // 取值0 || 1, 0 表示这个几口最终数据是json,1表示该接口返回array数据
                    outParam: [ // 接口返回的mock 数据详情, 这里数据存储的时候被转化为mongo数据的形式了
                        {
                            name: 'msg',
                            type: 0,
                            remark: '',
                            must: 1,
                            mock: '成功'
                        },
                        {
                            name: 'status', 
                            type: 2,
                            remark: '',
                            must: 1,
                            mock: true
                        },
                        {
                            name: 'code',
                            type: 1,
                            remark: '',
                            must: 1,
                            mock: 200
                        },
                        {
                            name: 'data',
                            type: 4,
                            remark: '',
                            mock: '',
                            data: [

                            ]
                        }
                    ]
                }
            ]
        }
    ]
}

接口详情数据被转化后的类型对应

    /*
    **  数据类型
        0: value, // string
        1: value, // number
        2: value, // boolean
        3: value.data, // object item in an array
        4: value.data, // an object
        5: null || undefined
    */

API

queryDocLeverModel(callback)

  • callback 必传 获取数据成功之后的回调函数
  • 函数内定义了变量host, port, projectId 均来源于config 的配置

config(options)

可以通过 doclevernode.config(options) 配置设置,目前的配置项如下:

- `host` doclever xin 的服务主机
- `port` 服务端口号(默认是 80)
- `projectId` 项目ID
- `wrapper` 返回数据的包装属性名,用于在php或vm中指定根属性名,默认为 `空`,如果设置为`空字符串` 或 `false`,则不包装

配置示例

var doclevernode = require('doclever-node-plugin-xin');

doclevernode.config({
    host: '',    //启动的服务主机
    port: '',           //端口号
    projectId: '5ab3213b5d30311201b752bc',  //项目ID
    wrapper: ''             //不需要包装
})

说明

  • 接口返回的数据可以直接通过 http://apidev.xin.com/xinmock/data?project=projectId 来查看
  • 具体的返回格式不用太关注,因为这个数据最终会转化为我们填写接口数据时传入的json 或者 array 形式的数据