json-api-mocker 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.ch.md +36 -5
  2. package/README.md +42 -11
  3. package/package.json +2 -2
package/README.ch.md CHANGED
@@ -1,4 +1,4 @@
1
- # JSON Mock Server
1
+ # JSON API Mocker
2
2
 
3
3
  一个轻量级且灵活的 Mock 服务器,通过 JSON 配置快速创建 RESTful API。
4
4
 
@@ -21,13 +21,13 @@
21
21
 
22
22
  ```bash
23
23
  # 使用 npm
24
- npm install json-mock-server
24
+ npm install json-api-mocker
25
25
 
26
26
  # 使用 yarn
27
- yarn add json-mock-server
27
+ yarn add json-api-mocker
28
28
 
29
29
  # 使用 pnpm
30
- pnpm add json-mock-server
30
+ pnpm add json-api-mocker
31
31
  ```
32
32
 
33
33
  ## 🚀 快速开始
@@ -70,12 +70,43 @@ pnpm add json-mock-server
70
70
 
71
71
  ### 2. 启动服务器
72
72
 
73
+ 有多种方式可以启动 Mock 服务器:
74
+
73
75
  ```bash
74
- npx json-mock-server
76
+ # 方式一:使用 npx(推荐)
77
+ npx json-api-mocker
78
+
79
+ # 方式二:使用 npx 并指定配置文件
80
+ npx json-api-mocker ./custom-config.json
81
+
82
+ # 方式三:如果全局安装了包
83
+ json-api-mocker
84
+
85
+ # 方式四:如果作为项目依赖安装
86
+ # 在 package.json 的 scripts 中添加:
87
+ {
88
+ "scripts": {
89
+ "mock": "json-api-mocker"
90
+ }
91
+ }
92
+ # 然后运行:
93
+ npm run mock
75
94
  ```
76
95
 
77
96
  现在你的 Mock 服务器已经在 `http://localhost:8080` 运行了!
78
97
 
98
+ 你会看到类似这样的输出:
99
+ ```bash
100
+ Mock 服务器已启动:
101
+ - 地址:http://localhost:8080
102
+ - 基础路径:/api
103
+ 可用的接口:
104
+ GET http://localhost:8080/api/users
105
+ POST http://localhost:8080/api/users
106
+ PUT http://localhost:8080/api/users/:id
107
+ DELETE http://localhost:8080/api/users/:id
108
+ ```
109
+
79
110
  ## 📖 配置指南
80
111
 
81
112
  ### 服务器配置
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- # JSON Mock Server
1
+ # JSON API Mocker
2
2
 
3
3
  A lightweight and flexible mock server that uses JSON configuration to quickly create RESTful APIs.
4
4
 
5
5
  <p align="center">
6
- <img src="https://img.shields.io/npm/v/json-mock-server" alt="npm version" />
7
- <img src="https://img.shields.io/npm/l/json-mock-server" alt="license" />
8
- <img src="https://img.shields.io/npm/dt/json-mock-server" alt="downloads" />
6
+ <img src="https://img.shields.io/npm/v/json-api-mocker" alt="npm version" />
7
+ <img src="https://img.shields.io/npm/l/json-api-mocker" alt="license" />
8
+ <img src="https://img.shields.io/npm/dt/json-api-mocker" alt="downloads" />
9
9
  </p>
10
10
 
11
11
  ## ✨ Features
@@ -20,14 +20,14 @@ A lightweight and flexible mock server that uses JSON configuration to quickly c
20
20
  ## 📦 Installation
21
21
 
22
22
  ```bash
23
- # 使用 npm
24
- npm install json-mock-server
23
+ # Using npm
24
+ npm install json-api-mocker
25
25
 
26
- # 使用 yarn
27
- yarn add json-mock-server
26
+ # Using yarn
27
+ yarn add json-api-mocker
28
28
 
29
- # 使用 pnpm
30
- pnpm add json-mock-server
29
+ # Using pnpm
30
+ pnpm add json-api-mocker
31
31
  ```
32
32
 
33
33
  ## 🚀 Quick Start
@@ -70,12 +70,43 @@ Create a `data.json` file in your project root:
70
70
 
71
71
  ### 2. Start the Server
72
72
 
73
+ There are several ways to start the mock server:
74
+
73
75
  ```bash
74
- npx json-mock-server
76
+ # Method 1: Using npx (Recommended)
77
+ npx json-api-mocker
78
+
79
+ # Method 2: Using npx with a custom config file
80
+ npx json-api-mocker ./custom-config.json
81
+
82
+ # Method 3: If installed globally
83
+ json-api-mocker
84
+
85
+ # Method 4: If installed as a project dependency
86
+ # Add this to your package.json scripts:
87
+ {
88
+ "scripts": {
89
+ "mock": "json-api-mocker"
90
+ }
91
+ }
92
+ # Then run:
93
+ npm run mock
75
94
  ```
76
95
 
77
96
  Now your mock server is running at `http://localhost:8080`!
78
97
 
98
+ You'll see output like this:
99
+ ```bash
100
+ Mock Server is running:
101
+ - Address: http://localhost:8080
102
+ - Base Path: /api
103
+ Available APIs:
104
+ GET http://localhost:8080/api/users
105
+ POST http://localhost:8080/api/users
106
+ PUT http://localhost:8080/api/users/:id
107
+ DELETE http://localhost:8080/api/users/:id
108
+ ```
109
+
79
110
  ## 📖 Configuration Guide
80
111
 
81
112
  ### Server Configuration
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "json-api-mocker",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "一个基于 JSON 配置的 Mock 服务器",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
8
- "json-mock-server": "dist/cli.js"
8
+ "json-api-mocker": "./dist/cli.js"
9
9
  },
10
10
  "files": [
11
11
  "dist",