Skip to content

Commit

Permalink
docs: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato committed Aug 11, 2020
1 parent 0b2efc0 commit 4228acc
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,30 @@ Amazon SQS for Deno
## Examples

Coming soon...
```ts
import { SQSQueue } from "https://deno.land/x/sqs@0.3.0/mod.ts";

// Create a queue using the queue url and credentials
const queue = new SQSQueue({
queueURL: "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue/",
accessKeyID: Deno.env.get("AWS_ACCESS_KEY_ID")!,
secretKey: Deno.env.get("AWS_SECRET_ACCESS_KEY")!,
region: "us-east-2",
});

// Send a message to this queue and print the message ID.
const res = await queue.sendMesssage({ body: "Hello World!" });
console.log("Sent message with id ", res.messageID);

// Receive a message from the queue:
const { messages } = await queue.receiveMessage();
for (const message of messages) {
console.log("Recieved message ", message.messageID, "and body", message.body);

// Delete the message after receiving it
await queue.deleteMessage(message.receiptHandle);
}
```

## Contributing

Expand Down

0 comments on commit 4228acc

Please sign in to comment.