Skip to main content

Configurations

Configurations are crucial for any application, and Warlock provides a simple way to manage your application configurations.

Config directory

All configurations are located inside src/config directory, they are automatically loaded when the application starts.

Environment variables

Before we proceed, there is an important note to be taken into consideration, which is the environment variables.

Environment Variables are important to any application to distinguish between different environments, like development, staging and production.

In that sense, when we define the app configurations, make sure to not include the information directly, use environment variables instead.

Configurations Types

Application configurations are the general application configurations, it contains the following types:

  1. app: General application configurations, like the application name, the application URL ...etc.
  2. Auth configurations: Authentication configurations
  3. Cache configurations: Cache configurations
  4. Database configurations: Database configurations
  5. Http + cors configurations: CORS configurations
  6. Log configurations: Logger configurations
  7. Validation configurations: Validation configurations
  8. uploads: Uploads configurations

Configuration Files

Because the configurations here are automatically loaded, each config file name is a special name that is used to load the configurations.

Here is the list of all available files that can be loaded:

note

All configuration files must export a default object that contains the configurations.

danger

Please note that each file in the config directory must be named as the way it was defined in the Configurations Types section.

App configurations

The app configurations contains simple data, like the application name, the application URL, debug mode ...etc.

  • baseUrl: The application base URL, it's used to generate the full URL for the application, you can not miss it, it is required.
  • timezone: The application timezone, it's used to set the timezone for the application, defaults to UTC.
  • localeCode: Default locale code

Base Url

Base Url is used to generate Urls to make sure it generates a proper URL for each generated url.

Timezone

Timezone is used to set the default timezone for the application, it's used to make sure that all dates are generated with the correct timezone.

tip

Monpulse depends on this timezone to generate the correct date for each user, so make sure to set it correctly.

localeCode

Locale code is used when the app is a multilingual (has more than one language) application, so make sure to provide the default locale code for the application.

This will be used as a default fallback when api is requested with invalid locale code or with no locale code at at all.