apimock-rs 4.7.0 β†’ 4.7.2

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 (2) hide show
  1. package/README.md +134 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # apimock-rs (API Mock)
2
+
3
+ [![npm](https://img.shields.io/npm/v/apimock-rs)](https://www.npmjs.com/package/apimock-rs)
4
+ [![crates.io](https://img.shields.io/crates/v/apimock?label=rust)](https://crates.io/crates/apimock)
5
+ [![License](https://img.shields.io/github/license/apimokka/apimock-rs)](https://github.com/apimokka/apimock-rs/blob/main/LICENSE)
6
+
7
+ [![Rust Documentation](https://docs.rs/apimock/badge.svg?version=latest)](https://docs.rs/apimock)
8
+ [![Dependency Status](https://deps.rs/crate/apimock/latest/status.svg)](https://deps.rs/crate/apimock)
9
+ [![Releases Workflow](https://github.com/apimokka/apimock-rs/actions/workflows/release-executable.yaml/badge.svg)](https://github.com/apimokka/apimock-rs/actions/workflows/release-executable.yaml)
10
+ [![App Docs Workflow](https://github.com/apimokka/apimock-rs/actions/workflows/docs.yaml/badge.svg)](https://github.com/apimokka/apimock-rs/actions/workflows/docs.yaml)
11
+
12
+ ![logo](docs/src/assets/logo.png)
13
+
14
+ Build a working REST API in seconds β€” without a backend.
15
+ Frontend blocked by an unfinished backend ?
16
+ Need stable API responses for UI tests or offline development ?
17
+ Drop JSON files into a folder and your API immediately exists.
18
+
19
+ ## Mock APIs easily 🎈 β€” just JSON and go
20
+
21
+ 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.
22
+ All you have to do to start up is just use folders and JSON without any config set.
23
+
24
+ - ❄️ Zero-config start.
25
+ - 🌬️ Fast to boot, light on memory.
26
+ - πŸͺ„ File-based and rule-based matching. Scripting supported.
27
+
28
+ ### Why `apimock-rs` ?
29
+
30
+ - The backend is not ready yet.
31
+ - You need stable API responses for UI testing.
32
+ - You want offline development.
33
+ - CI tests require a predictable API.
34
+ - Your mock data is becoming large.
35
+
36
+ ### Handles real project scale
37
+
38
+ As your project grows, your mock API grows, too. Large mock datasets often cause problems:
39
+
40
+ - Slow startup
41
+ - High memory usage
42
+ - Crashes during UI testing
43
+ - Unstable CI runs
44
+
45
+ apimock-rs does not preload responses. Each response file is read only when a request arrives using non-blocking I/O. This keeps:
46
+
47
+ - Startup nearly instant
48
+ - Memory usage minimal
49
+ - Stable behavior under repeated requests
50
+
51
+ as validated with k6 load testing.
52
+ You can run UI development and automated tests continuously without worrying about server instability.
53
+
54
+ ---
55
+
56
+ ## Quick start
57
+
58
+ Easy to start with [npm package](https://www.npmjs.com/package/apimock-rs).
59
+
60
+ ```sh
61
+ # install into your app project
62
+ npm install -D apimock-rs
63
+ # and go
64
+ npx apimock
65
+ ```
66
+
67
+ ```sh
68
+ # just use folders and JSON
69
+ mkdir -p api/v1/
70
+ echo '{"hello": "world"}' > api/v1/hello.json
71
+ npx apimock
72
+
73
+ # response
74
+ curl http://localhost:3001/api/v1/hello
75
+ # --> {"hello":"world"}
76
+ ```
77
+
78
+ You may also check it out with browser to visit http://localhost:3001/api/v1/hello .
79
+
80
+ You now have a running REST endpoint.
81
+
82
+ ### `npx apimock` variation
83
+
84
+ | command | result |
85
+ | --- | --- |
86
+ | `npx apimock` | Run with all default parameters. |
87
+ | `npx apimock -p 4000` | Run with custom port. |
88
+ | `npx apimock -d tests/apimock-dyn-route` | Run with custom root dir on server response. |
89
+ | `npx apimock -c apimock.toml` | Run with config file giving rich features. Running `npx apimock --init` beforehand is required. |
90
+
91
+ ### Vite project integration
92
+
93
+ An example of **scripts** section in **package.json** is as below.
94
+
95
+ **concurrently** is used to run the Vite and API mock servers simultaneously, while **cross-env** enables terminal output coloring. Before starting, ensure you run:
96
+
97
+ ```sh
98
+ npm install -D concurrently cross-env
99
+ ```
100
+
101
+ Edit package.json:
102
+
103
+ ```json
104
+ "scripts": {
105
+ "apimock": "npx apimock",
106
+ "dev": "cross-env CLICOLOR_FORCE=1 concurrently \"vite\" \"npm run apimock\""
107
+ }
108
+ ```
109
+
110
+ Run:
111
+
112
+ ```sh
113
+ npm run dev
114
+ ```
115
+
116
+ ---
117
+
118
+ ### πŸ“– Documentation - guides and references
119
+
120
+ For more details, **🧭 check out our [full documentation](https://apimokka.github.io/apimock-rs/)**.
121
+
122
+ - Configuration Reference: πŸ“‹ [View all settings here](https://apimokka.github.io/apimock-rs/user-guide/configuration-reference.html)
123
+
124
+ ---
125
+
126
+ ## Open-source, with care
127
+
128
+ This project is lovingly built and maintained by volunteers.
129
+ We hope it helps streamline your API development.
130
+ Please understand that the project has its own direction β€” while we welcome feedback, it might not fit every edge case 🌱
131
+
132
+ ## Acknowledgements
133
+
134
+ 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) / [thiserror](https://crates.io/crates/thiserror) / [anyhow](https://crates.io/crates/anyhow). In addition, [mdbook](https://github.com/rust-lang/mdBook) (as to workflows).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apimock-rs",
3
- "version": "4.7.0",
3
+ "version": "4.7.2",
4
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",