mirror of
https://github.com/typicode/json-server.git
synced 2025-08-02 02:53:21 +08:00
Add config file support
This commit is contained in:
@ -1,5 +1,10 @@
|
||||
# Change Log
|
||||
|
||||
## [0.8.9][2016-03-17]
|
||||
|
||||
* CLI can now read options from `json-server.json` if present
|
||||
* CLI option `-c/--config` to point to a different configuration file
|
||||
|
||||
## [0.8.8][2016-02-13]
|
||||
|
||||
### Fixed
|
||||
|
35
README.md
35
README.md
@ -252,6 +252,41 @@ Now you can access resources using additional routes.
|
||||
/blog/posts/1/show
|
||||
```
|
||||
|
||||
### CLI usage
|
||||
|
||||
```
|
||||
json-server [options] <source>
|
||||
|
||||
Options:
|
||||
--config, -c Path to config file [default: "json-server.json"]
|
||||
--port, -p Set port [default: 3000]
|
||||
--host, -H Set host [default: "0.0.0.0"]
|
||||
--watch, -w Watch file(s) [boolean]
|
||||
--routes, -r Path to routes file
|
||||
--static, -s Set static files directory
|
||||
--read-only, --ro Allow only GET requests [boolean]
|
||||
--no-cors, --nc Disable Cross-Origin Resource Sharing [boolean]
|
||||
--snapshots, -S Set snapshots directory [default: "."]
|
||||
--delay, -d Add delay to responses (ms)
|
||||
--id, -i Set database id property (e.g. _id) [default: "id"]
|
||||
--quiet, -q Suppress log messages from output [boolean]
|
||||
--help, -h Show help [boolean]
|
||||
--version, -v Show version number [boolean]
|
||||
|
||||
Examples:
|
||||
bin db.json
|
||||
bin file.js
|
||||
bin http://example.com/db.json
|
||||
```
|
||||
|
||||
You can also set options in a `json-server.json` configuration file.
|
||||
|
||||
```json
|
||||
{
|
||||
"port": 3000
|
||||
}
|
||||
```
|
||||
|
||||
### Module
|
||||
|
||||
If you need to add authentication, validation, you can use the project as a module in combination with other Express middlewares.
|
||||
|
Reference in New Issue
Block a user