Bogus API
A wrapper around the great json-server. It allows you to specify multiple REST resources. Pass in a directory of Javascript files to be required, and they become your REST endpoints.
Install
npm install bogus-api
Usage
start resourceDir: './my-resources' resourceUriPrefix: '/api/v1';
Each JS file in the my-resources
directory could look like:
var users = ;// Create 10 usersfor var i = 0; i < 10; i++ users;moduleexports = users;
Or it could look like:
moduleexports = "id": 1 "title": "json-server" "author": "typicode" "id": 2 "title": "test" "author": "ccnokes" ;
So you get a little more flexibility than with plain json-server
.
You can add or override routes using the Express API like so:
bogusAPI = ;var bogusServer = bogusAPIstart;
Options
Option | Description |
---|---|
port | Port the app runs on. 7001 by default. |
host | 0.0.0.0 by default. |
resourceUriPrefix | Prefixes all resources with a URI. |
resourceDir | Directory containing your resources. Default to sample-resources. |
proxy | Object containing the host and port of the URL to proxy to. No default. |
staticDir | Path to static directory to serve. |
staticUri | URI to serve static directory through. |