
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@mocks-rs/mocks
Advanced tools
Mock REST APIs from JSON with zero coding within seconds.
Complete Documentation - For detailed usage, advanced features, and examples.
npm install -g @mocks-rs/mocks
Or use without installing:
npx @mocks-rs/mocks --help
Create a JSON file using the init command:
npx @mocks-rs/mocks init storage.json
Or if installed globally:
mocks init storage.json
This creates a storage.json file with sample data. Use the --empty option to create an empty structure:
npx @mocks-rs/mocks init --empty storage.json
Or if installed globally:
mocks init --empty storage.json
Start the mock server using your JSON file:
npx @mocks-rs/mocks run storage.json
Or if installed globally:
mocks run storage.json
Example JSON structure:
{
"posts": [
{ "id": "01J7BAKH37HPG116ZRRFKHBDGB", "title": "first post", "views": 100 },
{ "id": "01J7BAKH37GE8B688PT4RC7TP4", "title": "second post", "views": 10 }
],
"profile": { "id": "01J7BAQE1GMD78FN3J0FJCNS8T", "name": "mocks" }
}
This automatically creates REST endpoints:
# List all posts
curl http://localhost:3000/posts
# Get a specific post
curl http://localhost:3000/posts/01J7BAKH37HPG116ZRRFKHBDGB
# Get profile (singleton resource)
curl http://localhost:3000/profile
# Create a new post
curl -X POST http://localhost:3000/posts \
-H "Content-Type: application/json" \
-d '{"title": "new post", "views": 0}'
# Health check
curl http://localhost:3000/_hc
For each resource in your JSON file, mocks automatically creates:
GET /{resource} - List all itemsGET /{resource}/{id} - Get specific itemPOST /{resource} - Create new itemPUT /{resource}/{id} - Replace entire itemPATCH /{resource}/{id} - Partial updateDELETE /{resource}/{id} - Delete itemGET /_hc - Health check (returns 204)For detailed information about advanced configuration, query parameters, filtering, and more features, visit the complete documentation.
This project is open source. Visit the GitHub repository to contribute or report issues.
This project is licensed under the MIT license.
FAQs
Mock REST APIs from JSON with zero coding within seconds.
We found that @mocks-rs/mocks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.