Skip to main content
100%

Node.JS Config example #dotenv #convict #nodejs

✓ Published0🌍 Public
AAnsonT
Last edited Aug 27, 2018
Created on Aug 27, 2018

This example demonstrates how to configure a Node.js application using the dotenv and convict libraries, showing a structured approach to managing environment-specific settings. It displays a configuration schema that defines properties like log level, environment, IP address, port, and Cassandra database credentials, with each field specifying a format, default value, and corresponding environment variable. The code uses dotenv to load environment files, including a custom path based on the NODE_ENV variable, and extends convict with a custom 'string-array' format that parses comma-separated values. The final configuration object is exported via `config.getProperties()`, and sensitive fields like the Cassandra password are marked with a `sensitive: true` flag.

AI-generated description

Similar vizzes