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

@abdokouta/react-config

v1.0.3

Published

NestJS-inspired configuration management with multiple drivers (Env, File, Firebase) for React

Readme

@abdokouta/config

NestJS-inspired configuration management with multiple drivers (Env, File, Firebase) for Refine applications.

Features

  • 🔧 Multiple drivers: Environment variables, File-based, Firebase
  • 🎯 Type-safe getters: getString(), getNumber(), getBool(), etc.
  • 🌍 Environment helper: Env.get(), Env.getBool(), etc.
  • 📁 File pattern scanning for config files
  • 🔄 Variable expansion support
  • 💾 Built-in caching
  • 🎨 Laravel and NestJS inspired API

Installation

npm install @abdokouta/config
# or
pnpm add @abdokouta/config

Quick Start

1. Using Environment Variables (Default)

import { Module } from '@abdokouta/container';
import { ConfigModule, ConfigService } from '@abdokouta/config';

@Module({
  imports: [
    ConfigModule.forRoot({
      envFilePath: '.env',
      isGlobal: true,
    }),
  ],
})
export class AppModule {}

// Use in your services
@Injectable()
export class DatabaseService {
  constructor(private config: ConfigService) {}

  getConnection() {
    return {
      host: this.config.getString('DB_HOST', 'localhost'),
      port: this.config.getNumber('DB_PORT', 5432),
      ssl: this.config.getBool('DB_SSL', false),
    };
  }
}

2. Using File-Based Configuration

@Module({
  imports: [
    ConfigModule.forRoot({
      driver: 'file',
      filePattern: 'config/**/*.config.ts',
      isGlobal: true,
    }),
  ],
})
export class AppModule {}

Create config files:

// config/database.config.ts
export default {
  host: process.env.DB_HOST || 'localhost',
  port: parseInt(process.env.DB_PORT || '5432'),
  database: process.env.DB_NAME || 'myapp',
};

// config/cache.config.ts
export default {
  driver: process.env.CACHE_DRIVER || 'memory',
  ttl: 300,
};

Access in your code:

const dbHost = this.config.get('database.host');
const cacheDriver = this.config.get('cache.driver');

ConfigService API

Type-Safe Getters

// Get string
config.getString('APP_NAME', 'MyApp');
config.getStringOrThrow('APP_NAME');

// Get number
config.getNumber('PORT', 3000);
config.getNumberOrThrow('PORT');

// Get boolean
config.getBool('DEBUG', false);
config.getBoolOrThrow('DEBUG');

// Get array (comma-separated)
config.getArray('ALLOWED_HOSTS', ['localhost']);

// Get JSON
config.getJson<MyType>('COMPLEX_CONFIG', defaultValue);

// Generic get
config.get<string>('KEY', 'default');
config.getOrThrow<string>('KEY');

// Check existence
config.has('KEY');

// Get all
config.all();

Env Helper

Use the Env helper for direct environment variable access:

import { Env } from '@abdokouta/config';

// Get string
const appName = Env.get('APP_NAME', 'MyApp');
const apiKey = Env.getOrThrow('API_KEY');

// Get number
const port = Env.getNumber('PORT', 3000);

// Get boolean
const debug = Env.getBool('DEBUG', false);

// Get array
const hosts = Env.getArray('ALLOWED_HOSTS', ['localhost']);

// Get JSON
const config = Env.getJson<MyConfig>('APP_CONFIG');

// Check existence
if (Env.has('FEATURE_FLAG')) {
  // ...
}

// Get all
const allEnv = Env.all();

Configuration Options

interface ConfigModuleOptions {
  // Driver type
  driver?: 'env' | 'file' | 'firebase';

  // Env driver options
  envFilePath?: string | string[];
  ignoreEnvFile?: boolean;
  expandVariables?: boolean;

  // File driver options
  filePattern?: string | string[];

  // Custom configuration
  load?: Record<string, any> | (() => Record<string, any>);

  // Module options
  isGlobal?: boolean;
  cache?: boolean;
  validate?: (config: Record<string, any>) => void;
}

Examples

Environment Variables with Expansion

ConfigModule.forRoot({
  envFilePath: '.env',
  expandVariables: true, // Enables ${VAR} expansion
});
BASE_URL=https://api.example.com
API_ENDPOINT=${BASE_URL}/v1

Multiple Environment Files

ConfigModule.forRoot({
  envFilePath: ['.env', `.env.${process.env.NODE_ENV}`],
});

Custom Configuration

ConfigModule.forRoot({
  load: {
    app: {
      name: 'MyApp',
      version: '1.0.0',
    },
  },
});

Validation

ConfigModule.forRoot({
  validate: (config) => {
    if (!config.DATABASE_URL) {
      throw new Error('DATABASE_URL is required');
    }
  },
});

Comparison with Other Packages

vs @abdokouta/cache and @abdokouta/logger

All three packages follow the same pattern:

// Cache
import cacheConfig from '@abdokouta/cache/config/cache.config';
CacheModule.forRoot(cacheConfig);

// Logger
import loggerConfig from '@abdokouta/logger/config/logger.config';
LoggerModule.forRoot(loggerConfig);

// Config (manages both!)
import { ConfigModule, ConfigService } from '@abdokouta/config';
ConfigModule.forRoot({ isGlobal: true });

// Now use ConfigService to get cache/logger settings
const cacheDriver = config.getString('CACHE_DRIVER', 'memory');
const logLevel = config.getString('LOG_LEVEL', 'debug');

License

MIT