Skip to content

DevCycleHQ-Sandbox/OFREP-bucketing-worker

Repository files navigation

OFREP Bucketing Worker

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.

Prerequisites

Getting Started

  1. Clone the repository:
git clone https://github.com/your-username/OFREP-bucketing-worker.git
cd OFREP-bucketing-worker
  1. Install dependencies:
npm install
  1. Create a .dev.vars file 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
  1. Update the wrangler.toml file 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" }

Development

To run the worker locally:

npm run dev

Deployment

To deploy the worker to your Cloudflare environment:

npm run deploy

Example Usage

An example implementation is provided in the example directory. To run the example:

  1. Navigate to the example directory:
cd example
  1. Install dependencies:
npm install
  1. Update the example's wrangler.toml with your account details and desired route.

  2. Deploy the example worker:

npm run deploy

API Endpoints

POST /ofrep/v1/evaluate/flags/:key?

Evaluates 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"
  }
}

Environment Variables

  • DVC_API_KEY: Your DevCycle Server API key
  • CF_ZONE_ID: Your Cloudflare Zone ID
  • CF_API_TOKEN: Your Cloudflare API token

License

[Add your license information here]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published