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

fflags-lib

v3.1.0

Published

Librería para gestionar feature flags con Redis usando DDD y arquitectura hexagonal

Readme

🧩 fflags-lib

Modular and extensible library for managing feature flags using Redis as storage. Based on Domain-Driven Design (DDD) principles and Hexagonal Architecture.


🚀 Features

  • ✅ Feature flag management: activate, deactivate, create, delete, retrieve.
  • 🧱 Hexagonal architecture (ports and adapters).
  • 🧠 Clear separation between domain, application, and infrastructure.
  • 🔌 Redis storage (can be extended to others).
  • 📦 Packaged as a library for reuse in multiple projects.
  • 🧪 Tested with Vitest.
  • ⚙️ Written in TypeScript and compatible with ESM/CJS.

📦 Installation

npm install fflags-lib

🧑‍💻 Usage Guide

1. Initialization

With the newly updated architecture, you can now instantiate the ManagerService by injecting the FeatureFlagRepository of your choice. You can use Redis, PostgreSQL, or MySQL.

First, choose the driver you want to use and instantiate its repository:

Option A: Redis (Default / Recommended for speed)

import { Redis } from 'ioredis';
import { ManagerService, RedisRepository } from "fflags-lib";

const redisClient = new Redis(); // defaults to localhost:6379
const repository = new RedisRepository(redisClient);
const managerService = ManagerService.getInstance(repository);

Option B: PostgreSQL

Make sure you have created the required feature_flags table (check schema.sql) and that you have pg installed (npm i pg).

import { PostgresRepository, ManagerService } from "fflags-lib";

const repository = new PostgresRepository({
    connectionString: "postgresql://user:password@localhost:5432/mydb"
});
const managerService = ManagerService.getInstance(repository);

Option C: MySQL

Make sure you have created the required feature_flags table (check schema.sql) and that you have mysql2 installed (npm i mysql2).

import { MysqlRepository, ManagerService } from "fflags-lib";

const repository = new MysqlRepository({
    uri: "mysql://user:password@localhost:3306/mydb"
});
const managerService = ManagerService.getInstance(repository);

2. Creating a Feature Flag

Create a new feature flag with a key, an initial state (boolean), and a description.

// Creates a flag named 'new-feature', sets it to true, and adds a description
await managerService.createFlag('new-feature', true, 'Enables the new user dashboard');

3. Retrieving Flags

You can get a specific flag or list them based on their status.

// Get a specific flag by its key
const myFlag = await managerService.getFlag('new-feature');

// List all flags
const allFlags = await managerService.getAllFlags();

// List only active flags
const activeFlags = await managerService.getActivatedFlags();

// List only inactive flags
const inactiveFlags = await managerService.getInactiveFlags();

4. Updating a Flag's Status

You can toggle a flag's status between active and inactive.

// Deactivate the flag
await managerService.deactivateFlag('new-feature');

// Reactivate the flag
await managerService.activateFlag('new-feature');

5. Deleting a Flag

When a feature is fully rolled out or no longer needed, you can remove its flag.

// Delete the flag entirely
await managerService.deleteFlag('new-feature');

6. Graceful Shutdown

Always remember to close the Redis connection safely when your application shuts down.

// Closes the Redis connection
await managerService.quit();

🧪 Tests

npm run test

⚙️ Configuration

To use with your own paths or tools, check:
•	tsconfig.json with configured baseUrl and paths.
•	tsup.config.ts for bundling.
•	vitest.config.ts for tests.

📌 Requirements

  • Node.js 18+
  • Redis 6+
  • ioredis 5+