mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 19:52:20 +08:00
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 <sebbe@sebbetop.local>
This commit is contained in:

committed by
GitHub

parent
5f71c0992e
commit
bd4693d414
@ -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.
|
||||
|
Reference in New Issue
Block a user