refox
v0.0.1
Published
<p align="center"> <img src="https://ooo.0o0.ooo/2016/09/09/57d2d4c79112f.png" alt="refox" width="190px">
Downloads
3
Readme
<br /><br />Lightweight mock server on top of <a href="https://github.com/koajs/koa">koa</a>
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