From bd4693d414020dea2d50e5b2a95d237c3b4f6dcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Bengteg=C3=A5rd?= Date: Sat, 5 Feb 2022 04:11:38 +0100 Subject: [PATCH] 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 --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1841dd8a6..50e8e1672 100644 --- a/README.md +++ b/README.md @@ -484,6 +484,8 @@ const router = jsonServer.router(path.join(__dirname, 'db.json')) For an in-memory database, simply pass an object to `jsonServer.router()`. +To add custom options (eg. `foreginKeySuffix`) pass in an object as the second argument to `jsonServer.router('db.json', { foreginKeySuffix: '_id' })`. + Please note also that `jsonServer.router()` can be used in existing Express projects. #### Custom routes example @@ -605,10 +607,12 @@ Returns middlewares used by JSON Server. * `noCors` disable CORS (default: false) * `readOnly` accept only GET requests (default: false) -__`jsonServer.router([path|object])`__ +__`jsonServer.router([path|object], [options])`__ Returns JSON Server router. +* options (see [CLI usage](#cli-usage)) + ### Deployment 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.