Socket
Book a DemoInstallSign in
Socket

sd-mock-server

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sd-mock-server

Easy to use, no frills mock server

latest
Source
npmnpm
Version
1.3.0
Version published
Maintainers
2
Created
Source

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

Keywords

mock

FAQs

Package last updated on 14 May 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts