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.
- npm:
@openfeature/flagd-ofrep-cf-worker - Package docs:
packages/js-ofrep-worker/README.md - Example worker:
examples/js-worker - Shared test fixtures:
shared/test-flags.json
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
npm install
npm run build
npm test
npm run test:smoke:worker
npm run lint
npm run formatFor the reference worker:
# Runs examples/js-worker with wrangler dev
npm run dev
# Deploys examples/js-worker with wrangler deploy
npm run deployThe worker in examples/js-worker demonstrates two flag sources:
- Bundled static flags from
examples/js-worker/src/flags.jsonfor local development and the default example flow - Per-token flag configs loaded from R2 when
FLAG_SOURCE=r2andFLAGS_R2_BUCKETis 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.
The repo has two similar flag sets for different purposes:
examples/js-worker/src/flags.jsonis the canonical sample config for the example worker andnpm run devshared/test-flags.jsonis the broader shared fixture set used by tests and other repository-level validation
@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.
Apache-2.0