Drosse is a stateful and programmable mock server written in javascript.
Based on h3, Drosse uses loki
to store your mock data in memory so you can modify them in your
POST
, PUT
, PATCH
and DELETE
requests.
It comes out of the box with all the features you need to completely simulate a backend API, making it the best companion for any frontend developer 🤓
Features
Tight to your project: your mocks and your mock-server are part of your project. You can run as many drosse instances as you want simultaneously.
Easy configuration: configuring drosse is as simple as writing its port number in a .drosserc.js
file and writing route definitions in a routes.json
file.
Cascading configs: routes are defined as a JSON tree of sub-paths - plugins (throttle, proxy, ...) are inherited by child routes.
Static mocks: write mocks directly in the routes.json
file (inline mode) or in JSON files (static mode).
Dynamic mocks: build dynamic responses in javascript and access to the persisted data api, the request object and the NodeJS environment.
Assets handling: serve multimedia files with patterns and wild cards for easy fallback.
Dynamic URL params: match any route/endpoint pattern with dynamic parameters => /api/users/:id
.
Data persistence: work with stateful and interactive mocks thanks to the in-memory JSON database accessible via an easy-to-use API.
Throttling: delay response time of your routes, even the proxied ones.
Proxying: super-flexible proxy mechanism with inheritance and overwriting of sub-routes (with different proxy or local route).
Middlewares: extend Drosse with custom express middlewares to fulfill your use cases.
Templates: use response templates to avoid repeating yourself.
Scraping: scrape proxied endpoints and save the content to Drosse's database or static files.
Extensible REPL CLI: build custom commands and execute them at runtime => simulate interaction with 3rp-party services.
Examples
Find example code in the examples folder.
Contact & Support
- Create a GitHub issue for bug reports, feature requests, or questions
- Add a ⭐️ star on GitHub or ☕️ buy us a coffee to support the project!
Development
- Clone this repository
- Install yarn globally using
npm install -g yarn
- Install dependencies using
yarn
- Build using
yarn build
oryarn build:stub
for live rebuild - Run drosse with
yarn serve examples/<example-folder-name>
Credits & License
Drosse is crafted by Jota and licensed under the MIT license.