Mocker
A proxy-pass server to mock backend data automatically.
Usage
const koa = ;const mocker = ;const app = ;app;
Modes
config.mode
is either false
or an object with attributes below:
-
mock
: BooleanTry to load responses from cache, and send requests when no cache data is found.
-
save
: BooleanFetch from remote and save the successful responses to cache directory (
config.dir
).
Backends
Backends should be an array of objects with attributes below:
-
prefix
: RequiredThe prefix to match URLs that should be by-passed to proxy.
-
host
: RequiredThe target host of proxy.
-
backend_prefix
: OptionalIf other than
null
, theprefix
inrequest.url
will be replaced tobackend_prefix
.