{"_id":"@51npm/freedom-middleware-mock2easy","_rev":"1-ce318786d177cfcabdccddd0fd42c2de","name":"@51npm/freedom-middleware-mock2easy","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@51npm/freedom-middleware-mock2easy","version":"1.0.0","description":"用于管理前端开发中用到的后端接口中间件服务","main":"./index.js","scripts":{"watch":"watchify -t brfs public/javascripts/app.js -o public/build/bundle.js -v","build":"browserify -t brfs  public/javascripts/app.js -o public/build/bundle.js","util":"browserify -t brfs  public/javascripts/util.js -o public/build/util.js","start":"npm run watch --ignore-watch='./doc/**' & nodemon ./bin/www"},"repository":{"type":"git","url":"git+https://github.com/51talk-design/freedom-middleware-mock2easy.git"},"author":{"name":"shangshanruoshui"},"maintainers":[{"name":"shangshanruoshui","email":"gxgongxueyuan123@163.com"}],"contributors":[{"name":"shangshanruoshui","email":"gxgongxueyuan123@163.com"}],"dependencies":{"async":"^1.4.2","body-parser":"~1.0.0","brfs":"^1.4.1","browserify":"^14.5.0","browserify-middleware":"^7.0.0","colors":"^1.1.2","cookie-parser":"~1.0.1","debug":"~0.7.4","express":"~4.2.0","insert-css":"^0.2.0","jade":"~1.3.0","mkdirp":"^0.5.1","mockjs":"^0.1.10","morgan":"~1.0.0","node.extend":"^1.1.5","nodemon":"^1.4.1","open":"0.0.5","q":"^1.4.1","static-favicon":"~1.0.0","underscore":"^1.8.3","watchify":"^3.4.0"},"devDependencies":{"angular":"^1.4.5","angular-sanitize":"^1.4.5","angular-translate":"^2.7.2","angular-ui-bootstrap":"^0.13.4","angular-ui-router":"^0.2.15","bootstrap":"^3.3.5","jquery":"^2.1.4","json2":"^0.4.0"},"_id":"@51npm/freedom-middleware-mock2easy@1.0.0","_shasum":"2e0a3c040a8888b1bbd22d5e9ddd64ea8cd0982b","_from":"mock2easy@","gitHead":"2c3675ce0ebf2a51579cf83fb238d3ca835dde04","bugs":{"url":"https://github.com/51talk-design/freedom-middleware-mock2easy/issues"},"homepage":"https://github.com/51talk-design/freedom-middleware-mock2easy#readme","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"shangshanruoshui","email":"gxgongxueyuan123@163.com"},"dist":{"integrity":"sha512-pA/7gBMVATgBcv1X6GIglnalsx9aZsTgOLDlqq+Z3qDwV+1pzYDUVa/IzYcBGrgGSDuSBDHawegTZJjdFhkMrg==","shasum":"4580940a3e196c83a4f7958f3e43fbd5949a896e","tarball":"https://registry.npmjs.org/@51npm/freedom-middleware-mock2easy/-/freedom-middleware-mock2easy-1.0.0.tgz","fileCount":80,"unpackedSize":4230238,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe0fDXCRA9TVsSAnZWagAAwTgP/RtPqrVqnBju2sI0J0RS\nOyKAoLu8YSbU/rNeDGhKnqIqlQlWxvZIcWBwNlEQ249fdOsMGYhtGX5QNqmH\nJbY4eWh3TtSEm2UEpsPHlWJodQ3kHpJYbadFIihZrEVYbokqsAp/lPaK4zOt\nH7y6++uWToQ4cg+qkM9dR/IYHruKULmz0qTey3ad1/4YcQM83FmlanwmIVoZ\n1fEhRhTJHxKV4jVkN+oiPgq9dbzM8GeA+ALGLxZwQ8AWMkQL2ZFc9ir4tRP2\nuFrTwHNYa/YOWXvsYyGZmyl+fpraSSmiK1zKQRhiKFCDjBPT7nNM2a81R2vo\nPols5MD6EvFigVnU7RNEZbQqjFXLnFb35sstOabuVRBDkyTtRNe+lSvnefEY\nIy6EHb6yu5M1cEeNOQW4aoGgRi9olaG+Idiv6Hr5RCP8AwdDxS3ZZUW8GY8n\nEu2YRnbWhB2JNnl9zruokyufAXE8X6RF55Fg6UyTQI7rQc04Y/IpggS093P6\nTj9+VUVEbCAyS/nAedgRmQy9m4dbbw0l973CuuJB31zHOg5xK+A61TDmOz3E\nFl7QlH/eOj93Gwa+9MUPtXWwUPh1HAFgzChD94PvWLrbGQu0KQ9upzq3mmFT\nQZwS6IVR8DnUEsk60eBjYZbD8PxUdjQA6RjSgeANl/grPO2WJXCBwiNorJH5\nlG9Q\r\n=p69S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHoKnC/w9b9Qv1h+F1CQqW0xhP0haFhdcmvi1brO5uDYAiANSZl3VOl0BW5qZqiSv4tAaruzDpOAG5H8k/LHvCTjFg=="}]},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/freedom-middleware-mock2easy_1.0.0_1590816983355_0.015725338533377986"},"_hasShrinkwrap":false}},"time":{"created":"2020-05-30T05:36:23.104Z","1.0.0":"2020-05-30T05:36:23.610Z","modified":"2022-04-04T10:47:55.412Z"},"maintainers":[{"name":"shangshanruoshui","email":"gxgongxueyuan123@163.com"}],"description":"用于管理前端开发中用到的后端接口中间件服务","homepage":"https://github.com/51talk-design/freedom-middleware-mock2easy#readme","repository":{"type":"git","url":"git+https://github.com/51talk-design/freedom-middleware-mock2easy.git"},"contributors":[{"name":"shangshanruoshui","email":"gxgongxueyuan123@163.com"}],"author":{"name":"shangshanruoshui"},"bugs":{"url":"https://github.com/51talk-design/freedom-middleware-mock2easy/issues"},"readme":"### 简介\n\n**freedom-middleware-mock2easy**是基于开源项目**mock2easy**修改而来的用于管理前端开发中用到的后端接口中间件服务，简单易用\n\n感谢mock2easy的作者，[访问mock2easy请点击](https://github.com/appLhui/mock2easy)\n\n### api提供参数设置\n\n```\noption:object类型，配置项目，目前只提供端口设置\n  - port:number类型，mock启动的端口\n  - doc:string类型，mock文档存储路径，可以不写，不写默认为当前目录下，即：__dirname + doc\n  - database:string类型，接口mock数据存储目录，可不写，不写默认为当前目录下，即：__dirname + mock2easy\n```\n\n### 如何使用\n\n```js\nconst mock2easy = require(\"@51npm/freedom-middleware-mock2easy\");\n(async function(){\n  await mock2easy({port:8080});\n})();\n```\n\n# mock2easy开源项目介绍\n\n##什么是mock2easy？\n\n1. 结合[Mockjs](http://mockjs.com/)使静态的接口活起来\n\n2. 接口自动化测试\n\n3. 接口地址重定向多功能于一身的工具\n\n4. 结合Gitbook整理专业接口文档\n\n5. 支持多平台暂时提供 grunt、gulp 和 webpack 平台。\n\n尝试一下一定会帮你解决很大问题～\n\n\n### 基本配置\n\n#### options.port\n\nType: `Number`\n\nDefault value: 3000\n\nservice port of the starting service\n\n启动的服务的端口号\n\n\n#### options.lazyLoadTime\n\nType: `Number`\n\nDefault value: 3000\n\nenable lazy-loading interface, the delayed time of executing the interface \n\n启动接口延时加载，调用接口的延迟时间 \n\n#### options.database\n\nType: `String`\n\nDefault value: `mock2easy`\n\nlocation of the generated interface data \n\n接口数据的生成位置\n\n#### options.doc\n\nType: `String`\n\nDefault value: `doc`\n\nlocation of the generated interface documents\n\n接口文档的生成位置\n\n\n#### options.curl\n\nType: `Object`\n\nDefault value: false\n\nBy default leave it blank. If not empty then instead of accessing the local mock data, use will access the service interface through Curl\n\n默认为不写，如果写了的话优先于Curl请求，所有的接口将不再访问本地的mock数据，改为通过Curl访问服务端的接口，我们可以通过这个参数轻松实现ajax请求重定向，我们的ajax可以轻松跨域访问，非常适合联调测试。\n\n```\n curl: {\n      domain: 'http://10.1.28.217:8080',\n       parameter: {\n       },\n       Cookie: ''\n    }\n```\n\n#### options.interfaceSuffix\n\nType: `Sting`\n\nDefault value:  `.json`\n\nDefault value is `.json`, all generated interface end with `.json`. All the interface end with ‘.action’, you can change the attribute to `.action`\n\n默认为`.json` ,产生的接口都是以`.json`为后缀的，若你的接口全部都是`.action`结尾的话，可以将该属性更改为`.action`。\n后缀不能设置为`.mock2easy` 该后缀已经占用。\n\n\n#### options.interfaceRule\n\nType: `RegEx`\n\nDefault value:  `null`\n\n接口拦截方案，通过正则表但是的方式进行请求接口拦截，如果`options.interfaceRule` 参数设定，则`options.interfaceSuffix` 将会失效。\n\n#### options.ignoreField\n\nType: `Array`\n\nDefault value: []\n\nDefault value is []. It is ok to add ignorable request parameters. Each time when sending request, these key words will not be verified.\n\n默认为[]，可以添加忽略的请求参数，在每次发起请求的时候不去校验这些字段，例如：`__preventCache`等字段，可能不是我们想要的校验的参数。\n\n#### options.preferredLanguage\n\nType: `String`\n\nDefault value: 'en'\n\n支持多语言，默认是英文，将 参数设为 `cn`，将展示为中文，欢迎提供其他语言的翻译支持，[国际化代码地址](https://github.com/appLhui/mock2easy/blob/master/server/translate.js)\n\nDefault value is en, en/cn  EN/中文\n\n\n### 不同的平台配置Demo\n\n#### Grunt\n\n[Grunt平台请使用插件](https://www.npmjs.com/package/grunt-mock2easy)\n\n#### Gulp\n\n```\ngulp.task('serve', ['styles', 'fonts'], function () {\n\n  // 在这配置mockeasy的配置\n  var options = {\n\toptions.port,\n    lazyLoadTime: 3000,\n    database: 'mock2easy',\n    doc: 'doc',\n    ignoreField: [],\n    interfaceSuffix: '.json',\n    preferredLanguage: 'en'\n  };\n\n // 启动mock2easy,注意demo例子里端口号为3000，请避开端口重复 \n  require('mock2easy')(options, function (app) {\n    try {\n      app.listen(options.port, function () {\n        console.log(('mock2easy is starting , please visit : http://localhost:' + options.port).bold.cyan);\n      });\n    } catch (e) {\n      console.log(e);\n    }\n  });\n\n\n  browserSync({\n    notify: false,\n    port: 9000,\n    server: {\n      baseDir: ['.tmp', 'app'],\n      routes: {\n        '/bower_components': 'bower_components'\n      },\n      middleware: [require('./mock2easy/do')] //注意这里来定义middleware ，如果不配置的话将不能对接口进行拦截\n    }\n  });\n\n  ...\n});\n```\n\n\n\n## Support of mockjs  mockjs的支持\n\nThe default folder for the generated documents is `./doc/`. Push it to git for direct review.\n\n文档生成默认在 `./doc/` 目录下，push 到 git 上可以直接查看\n\nSupport all the mockjs grammar, [Mockjs grammar examples](http://mockjs.com/demo/mock.html)\n\n支持所有的mockjs语法，[Mockjs语法样例](http://mockjs.com/demo/mock.html) \n\nIf you have any idea or suggestion, please connect me:lhui3it@gmail.com \n\n如果有好的建议和意见请联系我：lhui3it@gmail.com\n\n[Click here to view the use case>>](https://github.com/appLhui/grunt-mock2easy-demo) \n\n[使用案例请戳我>>](https://github.com/appLhui/grunt-mock2easy-demo) \n\n## Basic UI 基本界面\n\n#### Main UI 主界面\n\n1. Simulate the lazy-loading status. Easy to check if the loading status is properly handled\n\n   方面模拟访问延时状态，轻松检查 loading 状态是否合理处理。\n\n2. Record interface (similar to postman operation), easily access remote interface through curl, (make sure the system supports curl command). Also record the interface to the local interface base.\n\n   录制接口（类似 postman 操作），轻松通过 curl ( 保证系统支持curl命令 )访问远程接口，并将接口录制入本地接口库。\n\n3. Access local interface base, automatically check if the interface has any issue. Easy to keep the consistency of the code in local interface base and the code in js execute interface. Besides, make sure the interface document and script the same at real time\n\n   访问本地接口库，自动检查接口是否存在异常，轻松保持本地接口库代码和 js 调用接口代码保持一致，并且确保接口文档实时和脚本保持一致。\n\n\n![image](https://raw.githubusercontent.com/appLhui/grunt-mock2easy/master/img/index.png) \n\n#### 接口操作页面\n\n1. Dynamic interface, use [Mockjs](http://mockjs.com/demo/mock.html)as support, can dynamically and randomly generate the interface\n\n   动态接口，使用 [Mockjs](http://mockjs.com/demo/mock.html)  作为支持，可以动态随机生成接口。\n\n2. Dynamic interface can access any node and add comments.\n\n   动态接口，可以轻松在任何一个节点上加上注释。\n\n3. Static interface. If the interface data is too complex for mock2easy to meet your requirement. Please use static interface.\n\n   静态接口，如果接口数据过于复杂，mock2easy  无法满足您的需求，请选用静态接口。\n\n4. Switch between json and jsonp\n\n   json 和 jsonp 互相切换\n\n![image](https://raw.githubusercontent.com/appLhui/grunt-mock2easy/master/img/detail.png) \n\n#### Interface documentation 接口文档\n\n\n [Interface menu>>](https://github.com/appLhui/grunt-mock2easy-demo/blob/master/doc/menu.md)\n\n\n![image](https://raw.githubusercontent.com/appLhui/grunt-mock2easy/master/img/md_menu.png) \n\n [Interface details>>](https://github.com/appLhui/grunt-mock2easy-demo/blob/master/doc/demo/jsondemo.md)\n\n\n![image](https://raw.githubusercontent.com/appLhui/grunt-mock2easy/master/img/md_detail.png) \n\n\n\n\n\n","readmeFilename":"README.md"}