File tree 1 file changed +6
-5
lines changed 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -254,19 +254,20 @@ Now you can access resources using additional routes.
254
254
/blog/posts/1/show
255
255
```
256
256
257
- ### Use middlewares
257
+ ### Add middlewares
258
258
259
- You can use express middlewares with ` --middlewares ` option
259
+ You can add your middlewares from the CLI using ` --middlewares ` option:
260
260
261
261
``` js
262
- // middlewares .js
262
+ // first .js
263
263
module .exports = function (req , res , next ) {
264
264
res .Header (' X-Hello' , ' World' )
265
265
}
266
266
```
267
267
268
268
``` 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
270
271
```
271
272
272
273
### CLI usage
@@ -280,7 +281,7 @@ Options:
280
281
--host, -H Set host [default: "0.0.0.0"]
281
282
--watch, -w Watch file(s) [boolean]
282
283
--routes, -r Path to routes file
283
- --middlewares, -m Path to middlewares file
284
+ --middlewares, -m Paths to middleware files [array]
284
285
--static, -s Set static files directory
285
286
--read-only, --ro Allow only GET requests [boolean]
286
287
--no-cors, --nc Disable Cross-Origin Resource Sharing [boolean]
You can’t perform that action at this time.
0 commit comments