Skip to content

fengzilong/refox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

refox

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

npm build dependencies Gitter license

Status

still under heavy development, don't use it currently

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: true,
			test: function( url, req ) {
				if( /sync/.test( url ) ) {
					return true;
				}
			},
			resolve: function( url, req ) {
				// sync return
				return '{ "foo": "bar" }';
			}
		},
		{
			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

About

🍻 lightweight mock server on top of koa

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published