Giter Site home page Giter Site logo

xmocker-cli's Introduction

Build Status

前端mock用工具

介绍

本工具是定制的mock服务工具,主要针对的是特殊API进行的设置。特色:

  • 定义API使用WEB页面操作

  • API添加不仅依赖于URL链接,而是支持从输入参数中判断所属的API名称

  • 使用nodejs和Koa的function进行条件判断,可针对不同的数据返回自定义的结果

  • 使用本地文件数据库nedb,整个环境仅依赖于nodejs环境

  • 提供文件服务器,可执行gulp类型的构建,并提供页面刷新及url展示接口

说明

相比于 rap �和 yapi 等服务器类型的 Mock 服务, 本�仓库定位于工具服务, 由于使用了本地的�数据库,其单个库最大数据读取为 256M,所以不适合大量的 API 存储。 相比于服务器类型,主要侧重于编辑的灵活和自由,去中心化,避免多人编辑相互影响的问题, 同时也造成了 api 数据过于离散,API 数据交换相对麻烦一些。配合 webpack 的 proxyTable,使用更为方便一些。

Install

   git clone https://github.com/wenlonghuo/xmocker-cli
   cd xmocker-cli
   npm link --production

npm i -g xmocker-cli

使用

打开网页 http://localhost:6001 即可访问 在网页中添加完成项目相关的信息后,可使用命令进行启动对应的项目 命令:mocker

  Usage: mocker [options] [command]


  Options:

    -V, --version  output the version number
    -h, --help     output usage information

  Commands:

    start <proj>    启动项目
    stop <proj>     停止项目
    restart <proj>  重启项目
    list            列出项目
    exit            退出项目
    free <port>     杀掉指定端口
    here            在当前目录启动服务器,更多参数请使用 mocker here -h查看
    help [cmd]      display help for [cmd]

代理转发: 在输出处理函数中填入

const url = `${this.origin}${this.originalUrl.replace(this.path, '/url/new')}`
return this.tool.axios.get(url).then(res => res.data)

schema 使用的是json-gate https://github.com/oferei/json-gate

修改的项目

xmocker-cli's People

Contributors

wenlonghuo avatar justforuse avatar

Stargazers

 avatar 会飞 avatar 智瓶子 avatar Mosen avatar Luyakus avatar  avatar  avatar  avatar 刘明泰 avatar  avatar  avatar 哈雷不灰心 avatar  avatar Elvison avatar aricba avatar  avatar 熊小林 avatar mahongyin avatar Shinena Wang avatar Frank Wang avatar  avatar HiLize avatar alshat avatar dengjian avatar  avatar XiongAmao avatar Bruce Shum avatar  avatar  avatar  avatar  avatar 深红 avatar fantasy525 avatar Evan Tian avatar Jooger avatar

Watchers

James Cloos avatar Bruce Shum avatar  avatar  avatar  avatar Mosen avatar

xmocker-cli's Issues

配置好项目和接口,自己的项目如何启动

作者大大,配置好项目和接口,mock start XXX,显示如下:

后台管理界面运行于: http://localhost:6001 耗时: 1006 ms
项目启动成功: [borrowmoney] , 进程id: 15484, 端口号:8080

但是,在浏览器里访问localhost::8080 不能访问
请问怎么处理?

请问有示例吗

请问有示例吗?比如一个文档结构是什么样的,然后后台那里如何配置,可以在前台得到结果的一个最佳实践

mocker start 启动成功,但是提示cmd有问题

{ Error: spawn C:\windows\system32\cmd.exe ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn C:\windows\system32\cmd.exe',
path: 'C:\windows\system32\cmd.exe',

环境变量我也重新配了,node 版本 10.16.3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.