Note: This project is a work-in-progress. There are likely bugs and missing features!
This repository contains a Cloudflare Worker that implements the OpenFeature Remote Evaluation Protocol (OFREP) for feature flag evaluation. It provides a bucketing service that can be used with the OpenFeature SDK.
- Node.js (v16 or later)
- Wrangler CLI (v3 or later)
- A Cloudflare account with Workers enabled
- Clone the repository:
git clone https://github.com/your-username/OFREP-bucketing-worker.git
cd OFREP-bucketing-worker- Install dependencies:
npm install- Create a
.dev.varsfile in the root directory with your configuration:
DVC_API_KEY=your_devcycle_api_key
CF_ZONE_ID=your_cloudflare_zone_id
CF_API_TOKEN=your_cloudflare_api_token
- Update the
wrangler.tomlfile with your Cloudflare account details:
account_id = "your_cloudflare_account_id"Also update the route pattern if you want to use a different domain:
route = { pattern = "your-domain.com/*", zone_name = "your-domain.com" }To run the worker locally:
npm run devTo deploy the worker to your Cloudflare environment:
npm run deployAn example implementation is provided in the example directory. To run the example:
- Navigate to the example directory:
cd example- Install dependencies:
npm install-
Update the example's
wrangler.tomlwith your account details and desired route. -
Deploy the example worker:
npm run deployEvaluates feature flags based on the provided context. The endpoint accepts a JSON payload with the following structure:
{
"context": {
"user_id": "user-123",
"targetingKey": "optional-targeting-key",
"customAttribute": "value"
}
}DVC_API_KEY: Your DevCycle Server API keyCF_ZONE_ID: Your Cloudflare Zone IDCF_API_TOKEN: Your Cloudflare API token
[Add your license information here]