@adonisjs/config, providing a centralized configuration management system for your AdonisJS application.
Import
Overview
The Config module provides classes and utilities for managing application configuration files and environment-specific settings. It allows you to organize configuration data, access nested values, and manage different configurations for different environments.Classes
Config
The main configuration class for managing application settings.Constructor
Initial configuration object with key-value pairs
Methods
set
Sets a configuration value using dot notation.The configuration key in dot notation (e.g., ‘database.connection’)
The value to set for the configuration key
No return value
get
Retrieves a configuration value using dot notation.The configuration key in dot notation
Optional default value to return if the key doesn’t exist
The configuration value or default value if not found
has
Checks if a configuration key exists.The configuration key to check
Returns true if the key exists, false otherwise
Types
ConfigProvider
A provider type for lazy-loading configuration values.Example Usage
Notes
- Configuration keys use dot notation for accessing nested values
- The Config class is typically instantiated by the AdonisJS framework and available via dependency injection
- Configuration files are usually stored in the
config/directory of your application