createEntitlements
function createEntitlements<C>(options): Entitlements<C>;Defined in: src/engine.ts:475
Create the engine.
Type Parameters
Section titled “Type Parameters”| Type Parameter |
|---|
C extends AnyCatalog |
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
options |
EntitlementsOptions<C> |
Returns
Section titled “Returns”Entitlements<C>
Example
Section titled “Example”import { createEntitlements } from "@xtandard/entitlements";import { catalog } from "./catalog";
const ent = createEntitlements({ catalog });const decision = await ent.consume("org_42", "api_calls");if (!decision.allowed) return new Response(decision.reason, { status: 402 });