You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
README: added documentation for router options (#1290)
There was no documentation regarding adding router options when using
json-server as a module. This adds just enough documentation to
hopefully get you started.
Co-authored-by: Sebastian <[email protected]>
For an in-memory database, simply pass an object to `jsonServer.router()`.
486
486
487
+
To add custom options (eg. `foreginKeySuffix`) pass in an object as the second argument to `jsonServer.router('db.json', { foreginKeySuffix: '_id' })`.
488
+
487
489
Please note also that `jsonServer.router()` can be used in existing Express projects.
488
490
489
491
#### Custom routes example
@@ -605,10 +607,12 @@ Returns middlewares used by JSON Server.
605
607
*`noCors` disable CORS (default: false)
606
608
*`readOnly` accept only GET requests (default: false)
607
609
608
-
__`jsonServer.router([path|object])`__
610
+
__`jsonServer.router([path|object], [options])`__
609
611
610
612
Returns JSON Server router.
611
613
614
+
* options (see [CLI usage](#cli-usage))
615
+
612
616
### Deployment
613
617
614
618
You can deploy JSON Server. For example, [JSONPlaceholder](http://jsonplaceholder.typicode.com) is an online fake API powered by JSON Server and running on Heroku.
0 commit comments