sd-mock-server

1.3.0 • Public • Published

npm version Build Status coverage Dependency Status devDependency Status

sd-mock-server

Easy to use, no frills mock server.

This tool is useful when developing (and testing) frontend apps or backend services which talk to a multitude of external REST services. Instead of having to start locally (or in a remote dev environment) each external service, you can use sd-mock-server to easily write a local server which replicates the behavior of those services. Then, when developing our app/service, you start the local mock server and point your app/service to it.

Install

npm i --save-dev sd-mock-server

Quickstart

  • create a directory mock-server
  • create your first handler file mock-server/get.js
    module.exports = (req, res) => res.send("OK");
  • start the mock server
    $ node_modules/.bin/sd-mock-server
  • call the mocked route
    $ curl http://localhost:3456/

You add routes to the mock server by adding handler files at the corresponding path under the mock-server directory. Example:

mock-server
├── get.js -> handler for GET /
└── users
    ├── {userId}
    |   ├── get.js -> handler for GET /users/1
    |   └── put.js -> handler for PUT /user/1
    ├── get.js -> handler for GET /users
    └── post.js -> handler for POST /users

Documentation

Readme

Keywords

Package Sidebar

Install

npm i sd-mock-server

Weekly Downloads

0

Version

1.3.0

License

MIT

Last publish

Collaborators

  • pscanf
  • staticdeploy-npm-bot
  • davidebianchi