Skip to content

Commit 98670db

Browse files
committed
Update README.md
1 parent d607ff9 commit 98670db

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,19 +254,20 @@ Now you can access resources using additional routes.
254254
/blog/posts/1/show
255255
```
256256

257-
### Use middlewares
257+
### Add middlewares
258258

259-
You can use express middlewares with `--middlewares` option
259+
You can add your middlewares from the CLI using `--middlewares` option:
260260

261261
```js
262-
// middlewares.js
262+
// first.js
263263
module.exports = function (req, res, next) {
264264
res.Header('X-Hello', 'World')
265265
}
266266
```
267267

268268
```bash
269-
json-server db.json --middlewares middlewares.js
269+
json-server db.json --middlewares ./hello.js
270+
json-server db.json --middlewares ./first.js ./second.js
270271
```
271272

272273
### CLI usage
@@ -280,7 +281,7 @@ Options:
280281
--host, -H Set host [default: "0.0.0.0"]
281282
--watch, -w Watch file(s) [boolean]
282283
--routes, -r Path to routes file
283-
--middlewares, -m Path to middlewares file
284+
--middlewares, -m Paths to middleware files [array]
284285
--static, -s Set static files directory
285286
--read-only, --ro Allow only GET requests [boolean]
286287
--no-cors, --nc Disable Cross-Origin Resource Sharing [boolean]

0 commit comments

Comments
 (0)