npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-stubby-server

v0.4.0

Published

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

Downloads

152

Readme

Gulp Stubby Server

Build Status

Package Quality

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/foobar.json',
            'mocks/another-foobar-file.yaml',
            'mocks/foobar.yml',
            'mocks/another-foobar-file.js'
        ]
    };
    stubby(options, cb);
});

Options

options.files

Type: Array Default: null

Config files to run the server. It can accept a list of files or a glob pattern.

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.quiet

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.4.0

    • build(deps): Upgrade to stubby 4.1.1. The mute option has been renamed quiet to be more consistent with other cli tools. #17
  • 0.3.1 25.05.2020

    • Update dependencies #16
  • 0.3.0 06.05.2020

    • Upgrade to gulp 4 #14
    • Upgrade lodash version #15
  • 0.2.1 03.12.2018

    • Fix event-stream 3.3.6 vulnerability #13
  • 0.2.0 04.06.2016

    • Fix issue #9
    • Update Stubby package to 0.3.1
    • Update README file
    • Activate jshint task
  • 0.1.6 03.02.2016

    • Update glob package
  • 0.1.5 26.08.2015

    • Add YML files
    • Update package versions
    • Move gulp and gulp-util to dependencies
  • 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