Documentation
    Preparing search index...

    Config module eases the process of using configuration inside your AdonisJS applications.

    The config files are stored inside a dedicated directory, which are loaded and cached on application boot. Later you can access the values using the dot syntax.

    1. Given the config file is stored as config/app.ts with following content
    module.exports = {
    appKey: ''
    }
    1. You access the appKey as follows
    const config = new Config(configTree)
    config.get('app.appKey')
    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • config: Record<any, any> = {}

      Returns Config

    Methods

    • Get a tree of config imported from the config directory

      Returns Record<any, any>

    • Check if config value exists for a given key

      config.has('database.mysql')
      

      Parameters

      • key: string

      Returns boolean

    • Read value from the config. Make use of the dot notation syntax to read nested values.

      The defaultValue is returned when the original value is undefined.

      config.get('database.mysql')
      

      Type Parameters

      • T

      Parameters

      • key: string
      • OptionaldefaultValue: any

      Returns T

    • Define defaults for a config key. The defaults are merged with the value of the config key.

      Parameters

      • key: string
      • value: any

      Returns void

    • Update value for a key. No changes are made on the disk

      config.set('database.host', '127.0.0.1')
      

      Parameters

      • key: string
      • value: any

      Returns void