Skip to content

Commit

Permalink
docs: Fix README example
Browse files Browse the repository at this point in the history
  • Loading branch information
gnarea committed Jul 7, 2023
1 parent 2f53342 commit afa29b5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Then the `receiver` can be used to convert [`cloudevents`](https://www.npmjs.com

```typescript
import { makeReceiver } from '@relaycorp/cloudevents-transport';
import type { CloudEventV1, Message } from 'cloudevents';
import type { CloudEventV1 } from 'cloudevents';
import type { FastifyInstance, FastifyPluginOptions } from 'fastify';

export async function registerEventReceiver(server: FastifyInstance): Promise<void> {
Expand All @@ -60,10 +60,9 @@ export async function registerEventReceiver(server: FastifyInstance): Promise<vo
const convertMessageToEvent = await makeReceiver(transport);

server.post('/', async (request, reply) => {
const message: Message = { headers: request.headers, body: request.body };
let event: CloudEventV1<Buffer>;
try {
event = convertMessageToEvent(message);
event = convertMessageToEvent(request.headers, request.body);
} catch (err) {
return reply.status(400).send({ reason: err.message });
}
Expand Down

0 comments on commit afa29b5

Please sign in to comment.