Skip to content

Commit bd4693d

Browse files
trumtomteSebastian
andauthored
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]>
1 parent 5f71c09 commit bd4693d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,8 @@ const router = jsonServer.router(path.join(__dirname, 'db.json'))
484484

485485
For an in-memory database, simply pass an object to `jsonServer.router()`.
486486

487+
To add custom options (eg. `foreginKeySuffix`) pass in an object as the second argument to `jsonServer.router('db.json', { foreginKeySuffix: '_id' })`.
488+
487489
Please note also that `jsonServer.router()` can be used in existing Express projects.
488490

489491
#### Custom routes example
@@ -605,10 +607,12 @@ Returns middlewares used by JSON Server.
605607
* `noCors` disable CORS (default: false)
606608
* `readOnly` accept only GET requests (default: false)
607609

608-
__`jsonServer.router([path|object])`__
610+
__`jsonServer.router([path|object], [options])`__
609611

610612
Returns JSON Server router.
611613

614+
* options (see [CLI usage](#cli-usage))
615+
612616
### Deployment
613617

614618
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

Comments
 (0)