Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

推荐前端Mock工具——Mokia #78

Closed
varHarrie opened this issue Dec 14, 2021 · 1 comment
Closed

推荐前端Mock工具——Mokia #78

varHarrie opened this issue Dec 14, 2021 · 1 comment

Comments

@varHarrie
Copy link

源码仓库https://github.com/varHarrie/mokia
文档链接https://varharrie.github.io/mokia/

简介:一个开箱即用的API模拟服务器,帮助快速创建后端原型和数据模拟。

特性

  • 数据模拟:提供大量 mock 函数,支持生成数字、文本、日期、颜色、图片等,还支持嵌套、组合等结构复杂的数据。
  • 本地服务器:开发者无需关注服务器逻辑,通过命令就可以快速启动一个拟真的本地 mock 服务器。
  • 配置文件:基于JavaScript的配置文件,配合IDE的支持,可以很轻松地进行管理和维护。

用法

创建入口文件(index.js):

module.exports = {
  port: 3000,
  'GET /users'() {
    return this.list(() => ({ id: this.uuid(), name: this.fullName() }));
  },
  'GET /users/:id'(req) {
    return { id: req.params.id, name: this.fullName() };
  },
};

启动本地服务器:

npx mokia index.js --watch

打开浏览器进入http://localhost:3000/users (opens new window),你就能看到响应信息了。

@JN-H
Copy link
Collaborator

JN-H commented Dec 16, 2021

收,干得漂亮 :)

@JN-H JN-H closed this as completed Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants