Giter VIP home page Giter VIP logo

mockrest's Introduction

mock-restful

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 http://en.wikipedia.org/wiki/Representational_state_transfer

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.

Install

npm install mock-restful

Start

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.