mocks
Mock REST APIs from JSON with zero coding within seconds.
Complete Documentation - For detailed usage, advanced features, and examples.
Install
Homebrew
If you're a macOS Homebrew user, then you can install mocks
from homebrew-tap.
brew install mocks-rs/tap/mocks
Cargo
If you're a Rust programmer, mocks
can be installed with cargo
.
cargo install mocks
npm
If you're a Node.js user, you can install mocks
globally with npm
.
npm install -g mocks
Alternatively, you can run mocks
without installing using npx
.
npx @mocks-rs/mocks init storage.json
npx @mocks-rs/mocks run storage.json
Usage
Initialize a storage file
Create a JSON file using the init
command:
mocks init storage.json
This creates a storage.json
file with sample data. Use the --empty
option to create an empty structure:
mocks init --empty storage.json
Run a REST API server
Start the mock server using your JSON file:
mocks run storage.json
Example JSON structure:
This automatically creates REST endpoints:
curl http://localhost:3000/posts
curl http://localhost:3000/posts/01J7BAKH37HPG116ZRRFKHBDGB
curl http://localhost:3000/profile
Documentation
For detailed information about available routes, query parameters, advanced configuration, and more features, visit the complete documentation.
For development information, see DEVELOPMENT.md.
LICENSE
This project is licensed under the MIT license.