0.0.1-beta.13 • Published 10 months ago

soon-mock v0.0.1-beta.13

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

English | 中文

soon-mock

a mock server can add apis in seconds with web UI

Mock as Real Server so Soon

Official Document

Full Example

soon-admin
vue3 version:https://github.com/leafio/soon-admin-vue3
react version:https://github.com/leafio/soon-admin-react-nextjs

Installation/Getting Started

  • Add it to your project dev dependencies using NPM:
npm i -D soon-mock
  • Add a script to package.json,-p can config the server port:
{
  "scripts": {
    "mock": "soon-mock -p 8080"
  }
}
  • To start the server by simply running a command in the project folder.
npm run mock
  • When the server started, you can just access http://localhost:8080 in your browser.

Batch Generate APIs

  1. Switch to Quick Tab

  2. Input JSON / JS like this user, book are the schema name , just like table in database.

  {
    user:{
      name:'',
      age:1,
      job:''
    },
    book:{
      author:'',
      name:'',
      price:1
    }
  }
  1. Click the button Batch Generate.If a success toast is shown, the APIs has been generated.
MethodUrlDescription
get/api/userlist users
get/api/user/:idget user detail
post/api/useradd user
put/api/user/:idupdate user
delete/api/user/:iddelete user
get/api/booklist books
get/api/book/:idget book detail
post/api/bookadd book
put/api/book/:idupdate book
delete/api/book/:iddelete book
  1. Switch to API Tab, all APIs are shown, and can be edited.
    In the action , the code is run in a Express server controller.
    You can use req to get the request data, and use res to send the response.
    Details usage you can read Express js Documentation.

  2. Switch to Schema Tab, you can modify the schema fields.
    In the Default Value and Mock Data Input , you can write Single line js code.
    The faker ,mockjs and dayjs are ready for use to create the mock data or value.

  3. Switch to Data Tab, the mock datas are listed.

  4. Switch to Config Tab, these are some default settings.

English | 中文

soon-mock

一个有GUI的的mock服务器

一键模拟真实服务器

完整文档

完整示例

soon-admin 后台管理系统
vue3 版:https://github.com/leafio/soon-admin-vue3
react 版:https://github.com/leafio/soon-admin-react-nextjs

安装 & 启动

  • 添加 soon-mock 至项目的 dev dependencies
yarn add soon-mock -D
  • 添加一个 script 至 package.json , -p 可以配置 端口
{
  "scripts": {
    "mock": "soon-mock -p 8080"
  }
}
  • 启动 soon-mock 服务
yarn mock
  • 当服务启动后, 可在浏览器中访问网址 http://localhost:8080

批量生成API

仅需输入json,便可批量生成 API。

截图

  • 输入如下JSON / JSuser, book 为 schema 的名称 .
 {
    user:{
      name:'',
      age:1,
      job:''
    },
    book:{
      author:'',
      name:'',
      price:1
    }
  }
  • 点击批量生成 按钮 , 当显示成功提醒后,则下列 API 生成成功 | HTTP 方法 | API 地址 | 描述 | | ------ | ------------- | --------------- | | get | /api/user | 获取 user 列表 | | get | /api/user/:id | 获取 user 详情 | | post | /api/user | 添加 user | | put | /api/user/:id | 修改 user| | delete | /api/user/:id | 删除 user | | get | /api/book | 获取 book 列表 | | get | /api/book/:id | 获取 book 详情 | | post | /api/book | 添加 book | | put | /api/book/:id | 修改 book | | delete | /api/book/:id | 删除 book |
0.0.1-beta.10

11 months ago

0.0.1-beta.12

11 months ago

0.0.1-beta.11

11 months ago

0.0.1-beta.13

10 months ago

0.0.1-beta.9

11 months ago

0.0.1-beta.8

11 months ago

0.0.1-beta.7

11 months ago

0.0.1-beta.6

12 months ago

0.0.1-beta.5

12 months ago

0.0.1-beta.4

12 months ago

0.0.1-beta.3

12 months ago

0.0.1-beta.2

1 year ago

0.0.1-beta.1

1 year ago

0.0.1-beta.0

1 year ago