🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

stub-server

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stub-server

Stub server which do response depends on json configuration file

0.1.4
latest
Source
npm
Version published
Weekly downloads
29
-48.21%
Maintainers
1
Weekly downloads
 
Created
Source

Stub server is node.js based server for mocking request. Simple configuration format (JSON), responses can be in different files and types.

#Installation

npm i stub-server

#Usage

Like server:


var stubServer = require('stub-server');

stubServer.config('configuration.json');

stubServer.run();

Middleware:


var stubServer = require('stub-server');

stubServer.config('configuration.json');

stubServer.requestHandler(req, res, next);

Other usage examples are here

#Configuration

config - method that configure stub server with server params and stubs. It can be a string value (path to configuration JSON file) and a js object.

  • config.server - configuration for node.js server, that will be started.

    • port - port for stub server, default 9000
  • config.stub - array with requests.

Stub configuration:

  • request - request path [required]

  • response - response for this stub, can be a string, JSON, object, path to file [required]

  • file (true/false) - if it's true, and response is path to file, stub server return response file data with correct mime type.

  • strictData (if method is 'get' ignored, default false) - if true stub server select response with most appropriate data

  • data - response data in object format

  • headers (array) - add this headers to response

#Contributing

You are welcome :)

If you find bug or want some changes, please, create an issue

v.v.semykin@gmail.com - is my own email. Commits are also from work emails, that can be blocked :)

#License

GNU. Fill free to do something good for people

Keywords

stub

FAQs

Package last updated on 24 Jun 2015

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