apimock-rs 4.6.8 β 4.7.0
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/package.json +5 -5
- package/README.md +0 -136
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apimock-rs",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.7.0",
|
|
4
|
+
"description": "HTTP(S) mock server. Drop JSON files into a folder and your API immediately exists.",
|
|
5
5
|
"author": "nabbisen<nabbisen@scqr.net>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"repository": {
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"postinstall": "node postinstall.js"
|
|
20
20
|
},
|
|
21
21
|
"optionalDependencies": {
|
|
22
|
-
"@apimock-rs/bin-linux-x64-gnu": "4.6.
|
|
23
|
-
"@apimock-rs/bin-darwin-arm64": "4.6.
|
|
24
|
-
"@apimock-rs/bin-win32-x64-msvc": "4.6.
|
|
22
|
+
"@apimock-rs/bin-linux-x64-gnu": "4.6.9",
|
|
23
|
+
"@apimock-rs/bin-darwin-arm64": "4.6.9",
|
|
24
|
+
"@apimock-rs/bin-win32-x64-msvc": "4.6.9"
|
|
25
25
|
},
|
|
26
26
|
"keywords": [
|
|
27
27
|
"api",
|
package/README.md
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
# apimock-rs (API Mock)
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/apimock-rs)
|
|
4
|
-
[](https://crates.io/crates/apimock)
|
|
5
|
-
[](https://github.com/apimokka/apimock-rs/blob/main/LICENSE)
|
|
6
|
-
|
|
7
|
-
[](https://docs.rs/apimock)
|
|
8
|
-
[](https://deps.rs/crate/apimock)
|
|
9
|
-
[](https://github.com/apimokka/apimock-rs/actions/workflows/release-executable.yaml)
|
|
10
|
-
[](https://github.com/apimokka/apimock-rs/actions/workflows/docs.yaml)
|
|
11
|
-
|
|
12
|
-
Build a working REST API in seconds β without a backend.
|
|
13
|
-
|
|
14
|
-
Frontend blocked by an unfinished backend ?
|
|
15
|
-
Need stable API responses for UI tests or offline development ?
|
|
16
|
-
|
|
17
|
-
Drop JSON files into a folder and your API immediately exists.
|
|
18
|
-
|
|
19
|
-
## Quick start
|
|
20
|
-
|
|
21
|
-
Easy to start with [npm package](https://www.npmjs.com/package/apimock-rs).
|
|
22
|
-
|
|
23
|
-
```sh
|
|
24
|
-
# install into your app project
|
|
25
|
-
npm install -D apimock-rs
|
|
26
|
-
# and go
|
|
27
|
-
npx apimock
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
```sh
|
|
31
|
-
# just use folders and JSON
|
|
32
|
-
mkdir -p api/v1/
|
|
33
|
-
echo '{"hello": "world"}' > api/v1/hello.json
|
|
34
|
-
npx apimock
|
|
35
|
-
|
|
36
|
-
# response
|
|
37
|
-
curl http://localhost:3001/api/v1/hello
|
|
38
|
-
# --> {"hello":"world"}
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
You may also check it out with browser to visit http://localhost:3001/api/v1/hello .
|
|
42
|
-
|
|
43
|
-
You now have a running REST endpoint.
|
|
44
|
-
|
|
45
|
-
### Customization
|
|
46
|
-
|
|
47
|
-
Also, there's room to tweak things later with optional config file(s):
|
|
48
|
-
|
|
49
|
-
```sh
|
|
50
|
-
npx apimock --init
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Vite project integration
|
|
54
|
-
|
|
55
|
-
An example of **scripts** section in **package.json** is as below.
|
|
56
|
-
|
|
57
|
-
**concurrently** is used to run the Vite and API mock servers simultaneously, while **cross-env** enables terminal output coloring. Before starting, ensure you run:
|
|
58
|
-
|
|
59
|
-
```sh
|
|
60
|
-
npm install -D concurrently cross-env
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
Edit package.json:
|
|
64
|
-
|
|
65
|
-
```json
|
|
66
|
-
"scripts": {
|
|
67
|
-
"apimock": "npx apimock",
|
|
68
|
-
"dev": "cross-env CLICOLOR_FORCE=1 concurrently \"vite\" \"npm run apimock\""
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
Run:
|
|
73
|
-
|
|
74
|
-
```sh
|
|
75
|
-
npm run dev
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
### `npx apimock` variation
|
|
79
|
-
|
|
80
|
-
| command | result |
|
|
81
|
-
| --- | --- |
|
|
82
|
-
| `npx apimock` | Run with all default parameters. |
|
|
83
|
-
| `npx apimock -p 4000` | Run with custom port. |
|
|
84
|
-
| `npx apimock -d tests/apimock-dyn-route` | Run with custom root dir on server response. |
|
|
85
|
-
| `npx apimock -c apimock.toml` | Run with config file giving rich features. Running `npx apimock --init` beforehand is required. |
|
|
86
|
-
|
|
87
|
-
## Mock APIs easily π β just JSON and go
|
|
88
|
-
|
|
89
|
-
If youβre building or testing APIs, this tool makes mocking painless. Itβs super fast, efficient, and flexible when you need it to be.
|
|
90
|
-
All you have to do to start up is just use folders and JSON without any config set.
|
|
91
|
-
|
|
92
|
-
- βοΈ Zero-config start.
|
|
93
|
-
- π¬οΈ Fast to boot, light on memory.
|
|
94
|
-
- πͺ File-based and rule-based matching. Scripting supported.
|
|
95
|
-
|
|
96
|
-
### When to use `apimock-rs` ?
|
|
97
|
-
|
|
98
|
-
- The backend is not ready yet.
|
|
99
|
-
- You need stable API responses for UI testing.
|
|
100
|
-
- You want offline development.
|
|
101
|
-
- CI tests require a predictable API.
|
|
102
|
-
- Your mock data is becoming large.
|
|
103
|
-
|
|
104
|
-
### Handles real project scale
|
|
105
|
-
|
|
106
|
-
As your project grows, your mock API grows, too. Large mock datasets often cause problems:
|
|
107
|
-
|
|
108
|
-
- Slow startup
|
|
109
|
-
- High memory usage
|
|
110
|
-
- Crashes during UI testing
|
|
111
|
-
- Unstable CI runs
|
|
112
|
-
|
|
113
|
-
apimock-rs does not preload responses. Each response file is read only when a request arrives using non-blocking I/O. This keeps:
|
|
114
|
-
|
|
115
|
-
- Startup nearly instant
|
|
116
|
-
- Memory usage minimal
|
|
117
|
-
- Stable behavior under repeated requests
|
|
118
|
-
|
|
119
|
-
as validated with k6 load testing.
|
|
120
|
-
You can run UI development and automated tests continuously without worrying about server instability.
|
|
121
|
-
|
|
122
|
-
### π Documentation
|
|
123
|
-
|
|
124
|
-
For more details, **π§ check out [the docs](https://apimokka.github.io/apimock-rs/)**.
|
|
125
|
-
|
|
126
|
-
---
|
|
127
|
-
|
|
128
|
-
## Open-source, with care
|
|
129
|
-
|
|
130
|
-
[This project](https://github.com/apimokka/apimock-rs) is lovingly built and maintained by volunteers.
|
|
131
|
-
We hope it helps streamline your API development.
|
|
132
|
-
Please understand that the project has its own direction β while we welcome feedback, it might not fit every edge case π±
|
|
133
|
-
|
|
134
|
-
## Acknowledgements
|
|
135
|
-
|
|
136
|
-
Depends on [tokio](https://github.com/tokio-rs/tokio) / [hyper](https://hyper.rs/) / [toml](https://github.com/toml-rs/toml) / [serde](https://serde.rs/) / [serde_json](https://github.com/serde-rs/json) / [json5](https://github.com/callum-oakley/json5-rs) / [console](https://github.com/console-rs/console) / [rhai](https://github.com/rhaiscript/rhai). In addition, [mdbook](https://github.com/rust-lang/mdBook) (as to workflows).
|