Devcycle To Openfeature Nodejs Initialization Transform
Made for
Node.js
Last update
Mar 13, 2025
DevCycle to OpenFeature Node.js - Initialization Transform CodeMod
This Codemod will transform the initialization of the DevCycle Node.js Server SDK to use OpenFeature Node.js SDK.
- Calls to
initializeDevCycle()
should be replaced withnew DevCycleProvider()
where the same parameters used. - The variable named from the
initializeDevCycle()
call should be renamed to replaceclient
withprovider
. For example:devcycleClient
renamed todevcycleProvider
. - The new provider should be passed into
await OpenFeature.setProviderAndWait(devcycleProvider);
- C new
openFeatureClient
should be created fromOpenFeature.getClient()
- Usages of the variabled named from the
initializeDevCycle()
call should be updated to use theopenFeatureClient
instead.
Before
let devcycleClient: DevCycleClient;async function initializeDevCycleClient() {devcycleClient = await initializeDevCycle(DEVCYCLE_SERVER_SDK_KEY, {logLevel: "info",eventFlushIntervalMS: 1000,}).onClientInitialized();return devcycleClient;}function getDevCycleClient() {return devcycleClient;}export { initializeDevCycleClient, getDevCycleClient };
After
let openFeatureClient: Client;async function initializeDevCycleClient() {const Devcycleprovider = new DevCycleProvider(DEVCYCLE_SERVER_SDK_KEY, {logLevel: "info",eventFlushIntervalMS: 1000,});await OpenFeature.setProviderAndWait(Devcycleprovider);const openFeatureClient = OpenFeature.getClient();return openFeatureClient;}function getDevCycleClient() {return openFeatureClient;}export { initializeDevCycleClient, getDevCycleClient };
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community