Giter Site home page Giter Site logo

devservice's Introduction

DevService

基于nodejs的简易服务器,便于模拟各种场景用来进行开发测试。

使用方法:

  1. 运行node服务

    node index.js
    
  2. 打开代码编辑页面 http://127.0.0.1:8080 (端口号可以根据自己的需求进行调整)

    1.已保存的文件列表
    2.请求路径输入框
    3.代码编辑器
    4.主题选择与简介
    5.操作按钮

  3. 编写代码。填写请求路径并在代码编辑器里完成js代码之后,点击提交按钮或者使用快捷键cmd-s将代码提交到服务器。

  4. 检验请求结果。在浏览器地址栏输入 http://127.0.0.1:8080 + 请求路径 则会得到相应的json数据。

基本原理

在编辑js代码的时候,会有三个内置变量

resObj 接口返回的数据结构;
params 接口参数; 
timeout 延迟响应时间(毫秒)

nodejs运用vm来运行对应的js代码对resObj进行操作,组装需要的数据结构,最后以json字符串的格式输出。 相应的代码实现可以看 handler.js 中的 runCode 方法

使用建议

这个项目最主要的目的是为了模拟场景进行进行全面的逻辑测试,毕竟在正式的服务上有的场景是难以出现的。比如说可以通过设置 timeout,来延迟请求的相应,模拟出弱网场景。

devservice's People

Contributors

nyzhanggy avatar

Watchers

James Cloos avatar

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.