npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gatekeeper-dev/sdk

v0.1.2

Published

Client SDK for Gatekeeper - lightweight feature flag management

Readme

@gatekeeper-dev/sdk

@gatekeeper-dev/sdk is a lightweight TypeScript client for evaluating Gatekeeper feature flags from any JavaScript or TypeScript application.

It wraps Gatekeeper's runtime API and adds:

  • a simple isEnabled() interface
  • request timeouts
  • in-memory response caching
  • bounded cache size protection
  • safe fallback behavior through defaultValue

Install

npm install @gatekeeper-dev/sdk

Quick Start

import { createClient } from "@gatekeeper-dev/sdk";

const gatekeeper = createClient({
  apiKey: process.env.GATEKEEPER_API_KEY!,
  baseUrl: "http://localhost:3000",
});

const enabled = await gatekeeper.isEnabled("new_checkout", {
  userId: "user_123",
  attributes: {
    email: "[email protected]",
    plan: "pro",
  },
  defaultValue: false,
});

if (enabled) {
  console.log("Render new checkout");
}

API

createClient(config)

Creates a GatekeeperClient instance.

Configuration

| Option | Type | Required | Default | Description | | --- | --- | --- | --- | --- | | apiKey | string | yes | none | Project API key generated from the Gatekeeper dashboard | | baseUrl | string | yes | none | Base URL of the Gatekeeper deployment, for example https://flags.example.com | | cacheTtl | number | no | 60000 | Cache lifetime in milliseconds | | timeout | number | no | 5000 | Request timeout in milliseconds | | maxCacheSize | number | no | 1000 | Maximum number of cached evaluations kept in memory |

client.isEnabled(flagName, context?)

Evaluates a feature flag and returns Promise<boolean>.

Parameters

| Parameter | Type | Required | Description | | --- | --- | --- | --- | | flagName | string | yes | Name of the flag to evaluate | | context.userId | string | no | Stable user ID used for deterministic percentage rollout | | context.attributes | Record<string, string> | no | Attribute map used for rule matching | | context.defaultValue | boolean | no | Value returned if the API request fails |

client.clearCache()

Clears the SDK's local in-memory cache.

Runtime Behavior

Request format

The SDK sends:

  • GET /api/v1/evaluate
  • header: x-api-key
  • query param: flag
  • optional query params: userId, attributes

Cache behavior

The cache key includes:

  • flag name
  • userId
  • serialized attributes

This means evaluations for different users or different attribute sets are cached separately.

When the cache reaches maxCacheSize, the client:

  1. removes expired entries first
  2. if still full, removes the oldest inserted entry

Failure behavior

If the API call fails:

  • defaultValue is returned when provided
  • otherwise the SDK returns false

This makes the client safe to use in production code paths where availability matters more than strict runtime dependency on the control plane.

Example Patterns

Kill switch

const enabled = await gatekeeper.isEnabled("payments_enabled", {
  defaultValue: true,
});

Percentage rollout

const enabled = await gatekeeper.isEnabled("new_dashboard", {
  userId: user.id,
  defaultValue: false,
});

Attribute targeting

const enabled = await gatekeeper.isEnabled("internal_beta", {
  userId: user.id,
  attributes: {
    email: user.email,
    plan: user.plan,
    country: user.country,
  },
  defaultValue: false,
});

Backend Expectations

The SDK expects a Gatekeeper-compatible backend that exposes:

  • GET /api/v1/evaluate
  • API-key authentication through x-api-key
  • JSON response shaped like:
{ "enabled": true }

The reference implementation for that backend lives in the main project root.

Local Development

From the sdk/ directory:

npm install
npm run build

For watch mode:

npm run dev

The package is built with tsup and outputs:

  • dist/index.js for ESM
  • dist/index.cjs for CommonJS
  • dist/index.d.ts for types

Source Layout

sdk/
├── src/client.ts   # GatekeeperClient implementation
├── src/types.ts    # public config and evaluation types
└── src/index.ts    # package exports