From 6d49a466eb08a0c51c9c4080acf89b2a955899d4 Mon Sep 17 00:00:00 2001 From: dillonstreator Date: Tue, 16 Jan 2024 16:30:33 -0600 Subject: [PATCH] readme update --- README.md | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6196f40..6b7a485 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Let's look at an example of an HTTP API that allows a user to be invited where a ```ts import http from "node:http"; +import { randomUUID } from "node:crypto"; import { Client } from "pg"; import gracefulShutdown from "http-graceful-shutdown"; import { EventProcessor } from "txob"; @@ -81,7 +82,7 @@ const processor = EventProcessor( // use the AbortSignal `signal` to perform quick cleanup // during graceful shutdown enabling the processor to - // save handler result updates to the event + // save handler result updates to the event ASAP }, // other handler that should be executed when a `UserInvited` event is saved }, @@ -94,7 +95,7 @@ const server = http.createServer(async (req, res) => { if (req.url !== "/invite") return; // invite user endpoint - + const correlationId = randomUUID(); // or some value on the incoming request such as a request id try { @@ -116,7 +117,7 @@ const server = http.createServer(async (req, res) => { await client.query("COMMIT"); } catch (error) { - await client.query("COMMIT").catch(() => {}); + await client.query("ROLLBACK").catch(() => {}); } }); @@ -127,8 +128,6 @@ gracefulShutdown(server, { await processor.stop(); } }); - ``` - [other examples](./examples)