Run the command below to install the SDK:
npm install @fluxninja/aperture-js
The next step is to create an Aperture Client instance, for which, the address of the organization created in Aperture Cloud and API key are needed. You can locate both these details by clicking on the Aperture tab in the sidebar menu of Aperture Cloud.
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.
The created instance can then be used to start a flow:
The above code snippet is making
startFlow calls to Aperture. For this call,
it is important to specify the control point (
awesomeFeature in the example)
and business labels that will be aligned with the policy created in Aperture
Cloud. For request prioritization use cases, it's important to set a higher gRPC
deadline. This parameter specifies the maximum duration a request can remain in
the queue. For each flow that is started, a
shouldRun decision is made,
determining whether to allow the request into the system or to rate limit it. In
this example, we only see log returns, but in a production environment, actual
business logic can be executed when a request is allowed. It is important to
end call made after processing each request, to send telemetry data
that would provide granular visibility for each flow.