Skip to content

open-feature/flagd-ofrep-cf-worker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

flagd OFREP Cloudflare Worker

Warning: This project is under active development and is not yet ready for production use.

This repository contains a reusable Cloudflare Workers package for in-process flagd evaluation plus a reference worker that exposes OFREP evaluation endpoints. The package lives in packages/js-ofrep-worker, while examples/js-worker shows how to compose it with Hono, optional auth handling, and optional R2-backed flag loading.

Repository Guide

Repository Layout

flagd-ofrep-cf-worker/
├── packages/
│   └── js-ofrep-worker/           # Reusable package: @openfeature/flagd-ofrep-cf-worker
├── examples/
│   └── js-worker/                 # Reference Cloudflare Worker
└── shared/
    └── test-flags.json            # Shared fixtures used by tests and docs

Local Development

npm install
npm run build
npm test
npm run test:smoke:worker
npm run lint
npm run format

For the reference worker:

# Runs examples/js-worker with wrangler dev
npm run dev

# Deploys examples/js-worker with wrangler deploy
npm run deploy

Example Worker Notes

The worker in examples/js-worker demonstrates two flag sources:

  • Bundled static flags from examples/js-worker/src/flags.json for local development and the default example flow
  • Per-token flag configs loaded from R2 when FLAG_SOURCE=r2 and FLAGS_R2_BUCKET is configured

The package itself does not automatically add Hono routing, require authentication, or load flags from R2. Those behaviors are composed in the example worker around the package's OfrepHandler and extractAuthToken() helper.

Sample Flags

The repo has two similar flag sets for different purposes:

  • examples/js-worker/src/flags.json is the canonical sample config for the example worker and npm run dev
  • shared/test-flags.json is the broader shared fixture set used by tests and other repository-level validation

Workers Compatibility

@openfeature/flagd-core@^2.0.0 supports Cloudflare Workers and other V8 isolate runtimes without relying on dynamic code generation. This repo consumes the released package directly and uses disableDynamicCodeGeneration: true so targeting rules stay compatible with Workers runtime restrictions. The upstream work landed through open-feature/js-sdk-contrib#1480.

License

Apache-2.0

About

Cloudflare Worker for OpenFeature Remote Evaluation Protocol using flagd

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors