2 ms·
Surprised no one has mentioned what (to me) is the killer feature of REST, JSON-patch [1] Completely solves the PUT verb mutation issue and even allows event-s
by claytongulick 6y ago
Surprised no one has mentioned what (to me) is the killer feature of REST, JSON-patch [1]
Completely solves the PUT verb mutation issue and even allows event-sourced like distributed architectures with readability (if your patch is idempotent)
I married it to mongoose [2] and added an extension called json-patch-rules to whitelist/blacklist operations [3] and my API life became a very happy place.
I've replaced hundreds of endpoints with json-patch APIs and some trivial middleware.
When you couple that stack with fast-json-patch [4] on the client you just do a simple deep compare between a modified object and a cloned one to construct a patch doc .
This is the easiest and most elegant stack I've ever worked with.
[1] http://jsonpatch.com/ http://jsonpatch.com/
[2] https://www.npmjs.com/package/mongoose-patcher https://www.npmjs.com/package/mongoose-patcher
[3] https://github.com/claytongulick/json-patch-rules https://github.com/claytongulick/json-patch-rules
[4] https://www.npmjs.com/package/fast-json-patch https://www.npmjs.com/package/fast-json-patch