refox

0.0.1 • Public • Published

refox

<br /><br />Lightweight mock server on top of <a href="https://github.com/koajs/koa">koa</a>

npm build David Gitter license

Installation

$ npm i refox -g

Setup

Step 1: create config file in your project root

refox.config.js

const path = require( 'path' );
 
module.exports = {
    port: 5000,
    verbose: true,
    debug: true,
    mock: {
        sync: {
            test: function( url, req ) {
                if( /sync/.test( url ) ) {
                    return true;
                }
            },
            resolve: function( url, req ) {
                // sync return
                return '{ "foo": "bar" }';
            }
        },
        async: {
            test: function( url, req ) {
                if( /async/.test( url ) ) {
                    return true
                }
            },
            resolve: function( url, req ) {
                // or async callback
                var cb = this.async();
                setTimeout(function() {
                    cb( '123' );
                }, 1000);
            }
        },
    },
    compile: [
        {
            test: function( url, req ) {
                if( /sync/.test( url ) ) {
                    return true;
                }
            },
            loaders: [
                'pug?root=' + path.resolve( __dirname, 'fixtures/views' )
            ],
            // find your local file
            local: function( url, req ) {
                return path.resolve( __dirname, 'fixtures/views/test.pug' );
            }
        }
    ],
    static: [
        'lib'
    ]
}

Step 2: run refox

$ refox

you can also specify config file by using

$ refox -c file.config.js

CLI

Usage: refox [options]
 
lightweight mock server on top of koa
 
Options:
 
  -h, --help           output usage information
  -V, --version        output the version number
  -c, --config <path>  specify config file path
  -d, --debug          enable debug mode

License

MIT © fengzilong

Readme

Keywords

none

Package Sidebar

Install

npm i refox

Weekly Downloads

0

Version

0.0.1

License

MIT

Last publish

Collaborators

  • fengzilong