Open jellehak opened 2 years ago
Thumbs down from me on this. Considering json-server shouldnt ACTUALLY BE USED FOR PRODUCTION, this is a superfluous request...
Use a more performant and battle hardened JSON document storage like MongoDB or similar.
@ericnewton76 sad to hear a thumbs down. The idea is to have a better mock that comes closer to what an actual response on a production server would look like which is probably not prettified.
Actually, there is an issue with formatting not only in production. I really like to use json-server for pet projects or for test assignments and I use prettier there. And every time I commit I see tons of changes in db.json because Prettier formats only on a commit with lint-staged, which is very annoying. Can I somehow disable formatting?
Currently the JSONFile adapter of
lowdb
usesJSON.stringify(obj, null, 2)
which works nicely in most situations. However most 'production' situations would strip away the whitespace for performance. Therefor to have a better 'mock' server it would be nice to control the stringification process of the JSON ( both saving as reading ). Related file: https://github.com/typicode/lowdb/blob/main/src/adapters/JSONFile.tsPretty: JSON.stringify(obj, null, 2) Plain: JSON.stringify(obj)
Possible ideas