Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including mock-restful with all npm packages installed. Try it out:

var mockRestful = require("mock-restful")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

mock-restful v0.1.7

a mock rest service for development purposes


NPM version

Utility to fake the existence of a RESTful service, for development purposes (a bit like CANjs fixtures). Place some files with json object into the data folder and the service will respond to RESTful calls for POST, PUT, DELETE and GET.

It's stateful, so you can save data during a session. The data are not really written but only kept in a internal object, and each time you restart the application, it resets itself to the original data.

It's very simple - very. I've made it because I needed it, so it doesn't contain anything fancy. Now you can call the id anything you want (but it must be the same for every data file you use, and you must specify it in app.js).

Every file you add to the data folder creates its own route. I have provided two example files. If you launch the app, you will find that with the example files and default settings, the app will respond to calls to

[yourserver]:8888/stores // GET [yourserver]:8888/products // GET

And the various calls:

[yourserver]:8888/products/88 // GET, DELETE, etc...

I've used the conventions currently outlined in

Current version: 0.1.3 - Added command line parameters

Usage: put some json file(s) into the data folder. Start the app adding optionally the port number, path to data folder and the name of the id field. That's it - the app file will create a server and respond to restful calls, as long as they follow the object nesting on the json.


npm install mock-restful


node app.js [port] [path-to-data-folder] [id-string]


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free