Open huyansheng3 opened 6 years ago
Yes, that is frustrating. I too wasted a bit of time relying on the docs and looking for the problem in my code. @typicode, I could make a PR, but what is the proper change, actualizing the README based on the code, or vice versa?
+1 !!! this becomes me crazy!!!
This is definitely an issue. For me, moreso with the assumption that people want to use a "quick setup API server" as a static file server. The default should be to use the internal module unless the user passes either true
or a path to defaultsOpts.static
.
I ultimately had to scrap the default middleware and just run morgan
and body-parser
on my own, which was also frustrating because body-parser
is exported by json-server
, but morgan
isn't.
I'd be happy to submit a PR that adjusts the defaults and re-exports all of the middleware in case people need to roll their own like I just did.
jsonServer.defaults([options])
Returns middlewares used by JSON Server.
options static path to static files logger enable logger middleware (default: true) bodyParser enable body-parser middleware (default: true) noCors disable CORS (default: false) readOnly accept only GET requests (default: false)
as the doc say, bodyParser default is true!
but in the sourceCode
opts = objectAssign({ logger: true, static: staticDir }, opts)
only the logger and static has the default value! so maybe the doc is not correct?