Skip to content

Commit

Permalink
readme update
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonstreator committed Jan 16, 2024
1 parent 27e8d6e commit 6d49a46
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
},
Expand All @@ -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 {
Expand All @@ -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(() => {});
}
});

Expand All @@ -127,8 +128,6 @@ gracefulShutdown(server, {
await processor.stop();
}
});

```


[other examples](./examples)

0 comments on commit 6d49a46

Please sign in to comment.