moki

1.0.20 • Public • Published

Moki - [experimental]

... mocks your backend

experimental

Moki is an easy way to mock a rest-api and is usefull for Web- & Mobile-developers to build rest-based clients without the needs to run a real server.

Status

Build Status HitCount Gitter Dependency Status

Roadmap

Important: This software is permanently in development, so please use it carefuly.

Important: nodejs from V.6 doesn't support EventEmitter. So you will get a warning in console. currently i test this project only until v5.

Why? start with why

Frontend-developers doesn't like to work with broken services. They prefer to write UI code and expects a full working service with predictable behaviour. Later, if a product has a bug and for example fails in user acceptance tests, then a frontend-developer is the first instance who will be asked by the customer. The web-developer has to explain why the application doesn't work as expected. Even if the problem is a produced by a broken service.

Moki is a way to setup a rest-api with static (and dynamic) responses. So a web-developer get simple a way to develop against a not implemented service. Web-developer can configure response in different way, depends on a catched request and matched parameters.

Getting started

Requirements

  • nodejs
  • npm

Installation

Install moki with npm. To install moki global accessible you can use the -g option:

npm install -g moki

Working directory

Change to (project-) directory where you want to manage your rest-api mocks.

Configure mocks

To create a mock for a specified rest-request moki supports a json-based dsl. This json file with some mock-declarations inside we will call 'usecase'.

Example:

{
  "mocks" : [{
 
    "on" : {
      "endpoint": {
        "method": "get",
        "pattern": "/items",
        "path": "/items"
      }
 
    },
 
    "action" : { "items" : ["Apple", "Pineapple"] }
  }]
}

Save this content in a text file './usecases/usecase-1.json'.

Run

To run moki with above described usecase open command line and enter:

moki run usecase-1

Moki will resolve the name of usecase to a file, load the mock-declarations and start the server at http://localhost:8383/.

To test the endpoint open in the browser this url: http://localhost:8383/items

Important: http-Port is configurable

More docs

Alternative solutions

There are already some solutions on the market. Check them out. (List ist not complete)

Node based solutions

More mocking servers

Swagger based mocks

Services

The MIT License (MIT)

Copyright (c) 2016 Andreas Siebert

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Readme

Keywords

none

Package Sidebar

Install

npm i moki

Weekly Downloads

22

Version

1.0.20

License

MIT

Last publish

Collaborators

  • drdrej