Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-stubby-server-cli

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-stubby-server-cli

Node module which exposes Stubby Server CLI to node

  • 0.10.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
decreased by-70.59%
Maintainers
1
Weekly downloads
 
Created
Source

node-stubby-server-cli

| Module which exposes the Stubby Server API interface from node. The API is clean and simple to use. | Note that if you mute() the client, you cannot get any events so it's recommended not to do this.

Example usage

var cli = new CLI();

cli.admin(8001)
  .stubs(8000)
  .tls(8002)
  .help() // prints the help... note you still chain
  .mute() // supress output
  .data(__dirname + '/data.yml')
  .unmute() // enable output
  .start()
  .on(cli.events.REQUEST, function(data) {
    console.log(data);
  }).on(cli.events.RESPONSE, function(data) {
    console.log(data);
  });

  // server should be running after this...
  cli.once('LOADED_ROUTE', function() {
     next();
  });

  // note events won't be dispatch if muted

Gulp.js Example

var gulp = require('gulp');
var mocha = require('gulp-mocha');
var StubbyCLI = require('node-stubby-server-cli');
var cli = new StubbyCLI();

gulp.task('start:stubby', function(next) {
  cli.admin(<admin port>)
    .stubs(<stubs port>)
    .tls(<tls port>)
    .data(<path to data file>)
    .unmute()
    .start();

  // The server should be listening
  // after this event...
  cli.once('LOADED_ROUTE', function() {
    next();
  });
});

gulp.task('test', ['start:stubby'], function() {
  // run your tests after the stub server starts
});

gulp.task('stop:stubby', ['test'], function(next) {
  cli.kill();
  next();
});

// Default tasks to run
gulp.task('default', [
  'start:stubby',
  'test',
  'stop:stubby'
]);

Event.REQUEST Payload

{ 
  "time": "10:27:25",
  "method": "GET",
  "location": "stubs",
  "path": "/hello"
}

Event.RESPONSE Payload

{
  "time": "09:26:47",
  "statusCode": "404",
  "location": "stubs",
  "path": "/your/awesome/endpoint",
  "message": "is not a registered endpoint"
}

TODO

  • Write proper tests

Keywords

FAQs

Package last updated on 25 Mar 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc