Skip to content

requireEntitlement

function requireEntitlement<C>(
engine,
feature,
options
): (handler) => (request) => Promise<Response>;

Defined in: src/adapters/bun.ts:55

Guard a Bun route: resolve the customer from the Request, check (or consume) feature, answer 402 / 403 JSON when denied (401 when no customer), otherwise call the handler with the decision. Returns a wrapper to apply to handlers.

Type Parameter
C extends AnyCatalog
Parameter Type
engine Entitlements<C>
feature FeatureKey<C>
options RequireEntitlementOptions<Request>

(handler) => (request) => Promise<Response>