view-api 1.0.1 → 1.1.1
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.
- package/README.md +32 -4
- package/package.json +38 -13
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Perfect for frontend development, testing, and prototyping without a real backen
|
|
|
7
7
|
## ✨ Features
|
|
8
8
|
|
|
9
9
|
- Run mock APIs from a single JSON file
|
|
10
|
+
- Auto Refresh JSON file
|
|
10
11
|
- Customizable port
|
|
11
12
|
- Randomized success / error responses
|
|
12
13
|
- Zero setup for frontend teams
|
|
@@ -19,16 +20,39 @@ You don’t need to install it globally.
|
|
|
19
20
|
Run directly with `npx`:
|
|
20
21
|
|
|
21
22
|
```bash
|
|
22
|
-
npx
|
|
23
|
+
npx view-api start ./mock.json --port 4000
|
|
23
24
|
```
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
Or install globally:
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g view-api
|
|
30
|
+
view-api start mock.json
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🚀 Usage
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
view-api start <config-path> [options]
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Options
|
|
40
|
+
|
|
41
|
+
| Option | Description | Default |
|
|
42
|
+
| -------------- | ---------------------- | ------- |
|
|
43
|
+
| `--port`, `-p` | Port to run the server | `3000` |
|
|
44
|
+
|
|
45
|
+
Example:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
view-api start src/mocks/mock.json --port 4000
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 📄 Mock Config Format
|
|
28
52
|
|
|
29
53
|
```json
|
|
30
54
|
{
|
|
31
|
-
"version": "1.0",
|
|
55
|
+
"version": "1.0.0",
|
|
32
56
|
"routes": {
|
|
33
57
|
"GET /products": {
|
|
34
58
|
"behavior": {
|
|
@@ -56,3 +80,7 @@ You gotta use this json structure in able to use the api
|
|
|
56
80
|
}
|
|
57
81
|
}
|
|
58
82
|
```
|
|
83
|
+
|
|
84
|
+
## 📜 License
|
|
85
|
+
|
|
86
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,26 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "view-api",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "",
|
|
5
|
-
"
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "Run mock APIs locally from a JSON configuration file",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"view-api": "./bin/mock-runner.js"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/RidloGhifary/view-api"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/RidloGhifary/view-api",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/RidloGhifary/view-api/issues"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"bin",
|
|
19
|
+
"src",
|
|
20
|
+
"README.md"
|
|
21
|
+
],
|
|
6
22
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"
|
|
23
|
+
"dev": "nodemon bin/mock-runner.js start src/mocks/mock.json",
|
|
24
|
+
"start": "node bin/mock-runner.js",
|
|
25
|
+
"prepublishOnly": "npm run lint || true"
|
|
9
26
|
},
|
|
10
|
-
"
|
|
11
|
-
"mock
|
|
27
|
+
"keywords": [
|
|
28
|
+
"mock",
|
|
29
|
+
"api",
|
|
30
|
+
"mock-server",
|
|
31
|
+
"cli",
|
|
32
|
+
"frontend",
|
|
33
|
+
"testing",
|
|
34
|
+
"json"
|
|
35
|
+
],
|
|
36
|
+
"author": "Ridlo",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18"
|
|
12
40
|
},
|
|
13
|
-
"keywords": [],
|
|
14
|
-
"author": "",
|
|
15
|
-
"license": "ISC",
|
|
16
|
-
"type": "module",
|
|
17
41
|
"dependencies": {
|
|
18
42
|
"commander": "^14.0.2",
|
|
19
43
|
"cors": "^2.8.5",
|
|
20
|
-
"dotenv": "^17.2.3",
|
|
21
44
|
"express": "^5.2.1",
|
|
22
45
|
"helmet": "^8.1.0",
|
|
23
|
-
"morgan": "^1.10.1"
|
|
46
|
+
"morgan": "^1.10.1"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
24
49
|
"nodemon": "^3.1.11"
|
|
25
50
|
}
|
|
26
51
|
}
|