Portable api faker and random data generator built upon Faker. It serves both as a static file server from either the execution path or given directory. This might come handy if you are working on front end code without a possibility to wire up a backend.
$ (sudo) npm install cpthook --global
$ hook init $ hook serve
That's basically all there's to it.
Usage: hook [options] Options: init Initialize configuration serve Starts server -h, --help output usage information -p, --port <port> Port on which to run server. Defaults to 7000 -c, --config <file> Location of configuration json file. (Generated by "hook init"). Defaults to ./.cpthook.config -d, --dir <dir> Directory of which to serve static files from. Defaults to ./
Initialize json configuration file;
$ hook init
init creates a
.cpthook.config file which contains configuration for your web server:
The configuration file consists of objects that must contain
routeon which respond to
repeathow many json objects to fake. Defaults to 1 (one)
datathe data to respond with
Next up, we're ready to sail away;
$ hook serve
GET /companies will (with configuration above) respond with: