1.0.7 • Published 5 years ago

http-patch-builder v1.0.7

Weekly downloads
1
License
ISC
Repository
-
Last release
5 years ago

--------------------------------------PATCH example-----------------------------------------------

PATCH /users/123

{ "op":"test", "path":"/email/id", "value":"sourav@outlook.com", "from":"/name/first" }, { "op":"test", "path":"/email/id", "value":"sourav@outlook.com", "from":"/name/first" }

-----------------------------------------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.

{ "op":"test", "path":"/email/id", "value":"sourav@outlook.com", "from":"/name/first" }, { "op":"test", "path":"/email/id", "value":"sourav@outlook.com", "from":"/name/first" }

--------------------------------please-do-not-patch-like-an-idiot---------------------------------

https://williamdurand.fr/2014/02/14/please-do-not-patch-like-an-idiot/

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago