cloudflare-queue-consumer
Build CloudFlare Queues applications without the boilerplate. Just define an async function that handles the message processing.
Based on sqs-consumer.
Note: This package is still in development and should be used with caution.
Installation
To install this package, simply enter the following command into your terminal (or the variant of whatever package manager you are using):
npm install @bbc/cloudflare-queue-consumer
Documentation
Visit https://bbc.github.io/cloudflare-queue-consumer/ for the full API documentation.
Usage
import { Consumer } from "cloudflare-queue-consumer";
const consumer = new Consumer({
accountId: process.env.ACCOUNT_ID,
queueId: process.env.QUEUE_ID,
handleMessage: async (message) => {
},
});
consumer.start();
TODO: Add more information
Credentials
In order to authenticate with the CloudFlare API, you will need to create an API token with read and write access to CloudFlare Queues, more information can be found here.
Copy that token and set it as the value for an environment variable named QUEUES_API_TOKEN
.
Example project
You'll aldo find an example project in the folder ./example
, set the variables ACCOUNT_ID
and QUEUE_ID
and then run this with the command pnpm dev
.
Contributing
We welcome and appreciate contributions for anyone who would like to take the time to fix a bug or implement a new feature.
But before you get started, please read the contributing guidelines and code of conduct.
License
CloudFlare Queue Consumer is distributed under the Apache License, Version 2.0, see LICENSE for more information.