1.0.7 • Published 5 years ago
http-patch-builder v1.0.7
--------------------------------------PATCH example-----------------------------------------------
PATCH /users/123
-----------------------------------------Example--------------------------------------------------
createTestPatch(): void {
const patchBodyElement = PatchBodyItemBuilder.withDefaults()
.withOperation(PatchOperation.TEST)
.withTargetPath('/email')
.appendTargetPath('id')
.withValue('sourav@outlook.com')
.withFromPath('/name')
.appendFromPath('first')
.build();
const anotherPatchBodyElement = PatchBodyItemBuilder.withDefaults()
.withOperation(PatchOperation.TEST)
.withTargetPath('/email')
.appendTargetPath('id')
.withValue('sourav@outlook.com')
.withFromPath('/name')
.appendFromPath('first')
.build();
const patchBody = PatchBodyBuilder.withNoChange().addChangeElement(patchBodyElement).addChangeElement(anotherPatchBodyElement).build();
console.log(JSON.stringify(patchBody));
return-> A request patch body which follow proper format.
--------------------------------please-do-not-patch-like-an-idiot---------------------------------
https://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/