Skip to main content
Version: 2.25.2

Manually setting feature control points

Aperture JavaScript SDK can be used to manually set feature control points within a JavaScript service.

To do so, first create an instance of ApertureClient:

API Key

You can create an API key for your project in the Aperture Cloud UI. For detailed instructions on locating API Keys, refer to the API Keys section.

import { ApertureClient, Flow, FlowStatusEnum } from "@fluxninja/aperture-js";

export const apertureClient = new ApertureClient({
address: "ORGANIZATION.app.fluxninja.com:443",
agentAPIKey: "API_KEY",
});

The created instance can then be used to start a flow:

async function handleRequest(req, res) {
const flow = await apertureClient.StartFlow("feature-name", {
labels: {
label_key: "some_user_id",
},
grpcCallOptions: {
deadline: Date.now() + 300, // ms
},
});

if (flow.ShouldRun()) {
// Do Actual Work
} else {
// Handle flow rejection
flow.SetStatus(FlowStatusEnum.Error);
}

if (flow) {
flow.End();
}
}

For more context on using the Aperture JavaScript SDK to set feature control points, refer to the example app available in the repository.