Giter Club home page Giter Club logo

gulp-stubby-server's Introduction

Gulp Stubby Server

Build Status

A Gulp plugin for setting up a Stubby mock server based on YAML/JSON/JS configuration files.

Inspired by Grunt Stubby.

Getting Started

npm install gulp-stubby-server --save-dev

The "stubby" task

Usage Examples

Default Options

gulp.task('stubby', function(cb) {
    var options = {
        files: [
            'mocks/*.{json,yaml,js}'
        ]
    };
    stubby(options, cb);
});

Custom Options

gulp.task('stubby', function() {
    var options = {
        callback: function (server, options) {
          server.get(1, function (err, endpoint) {
            if (!err)
             console.log(endpoint);
          });
        },
        stubs: 8000,
        tls: 8443,
        admin: 8010,
        files: [
            'mocks/*.{json,yaml,js}'
        ]
    };
    stubby(options, cb);
});

Options

options.stubs

Type: Number Default value: 8882

Port number to run the stubs portal

options.tls

Type: Number Default value: 7443

Port number to run the stubs portal over https

options.admin

Type: Number Default value: 8889

Port number to run the admin portal

options.data

Type: Array/Object Default value: null

JavaScript Object/Array containing endpoint data. This option will be automatically filled from the JSON/YAML config files, however you can additionally add a customized data

options.location

Type: String Default value: localhost

Address/hostname at which to run stubby

options.relativeFilesPath

Type: Boolean Default value: false

When you use the 'file' property for the request/response config Objects, enabling this options the data file path is relative to the the config file where it has been declared.

options.key

Type: String Default value: null

Path to keyfile contents (in PEM format)

options.cert

Type: String Default value: null

Certificate file path contents (in PEM format)

options.pfx

Type: String Default value: null

Pfx file path contents (mutually exclusive with key/cert options)

options.watch

Type: String Default value: null

Filename to monitor and load as stubby's data when changes occur

options.mute

Type: Boolean Default value: true

Pass in false to have console output (if available)

options.callback

Type: Function Default value: null

Callback function when the server starts successfully. The passed arguments are:

  • server - The Stubby server instance object
  • options - The server config options object

options.persistent

Type: Boolean Default value: false

Run the task in a persistent keep-alive server mode. Other tasks not will run until the Stubby server stops

API

stop

Allows you to programmatically shutdown the stubby server.

stubbyServer.stop();

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style.

Add unit tests for any new or changed functionality. Lint and test your code using Gulp.

Testing

Clone the repository

$ git clone https://github.com/felixzapata/gulp-stubby-server.git && cd gulp-stubby-server

Install dependencies

$ npm install

Run tests

$ npm test

Release History

  • 0.1.4 16.07.2015

    • It adds a method to allows you to programmatically shutdown the stubby server.
  • 0.1.3 09.12.2014

    • Fix(package.json): glob should be a dependency instead of devDependency
  • 0.1.2 05.12.2014

    • Fix(index.js): on stubby error, calling the callback should be the last action
    • Fix(package.json): gulp-util must be as a dependency
  • 0.1.1 27.11.2014

    • Changes repository name
  • 0.1.0 27.11.2014

    • Initial release

License

Under MIT license

gulp-stubby-server's People

Contributors

felixzapata avatar surf66 avatar thrashr888 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.