Socket
Socket
Sign inDemoInstall

auto-reload-config

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    auto-reload-config

Auto-reload-config is a config loader that automatically reloads the config file(.js,.cjs,.json) without restarting the application when it is modified. It is designed to load different configuration files based on the value of an environment variable, an


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Auto-reload-config is a config loader that automatically reloads the config file(.js,.cjs,.json) without restarting the application when it is modified. It is designed to load different configuration files based on the value of an environment variable, and it can override fields in the configuration file with the same name suffixed with "cover" file.

Installation

npm install auto-reload-config

Usage

Create config/config.js file with the following content in workdir:

module.exports = {
  key: "your key",
};
import autoReloadConfig from 'auto-reload-config');
autoReloadConfig.get('key', 'default key');
//your key
autoReloadConfig.get('key2', 'default key');
//default key

use custom path

import autoReloadConfig from 'auto-reload-config');
autoReloadConfig.setup({ configDir: () => path.join('..', "customConfig") });
autoReloadConfig.get('key', 'default key');
//your key

use env to load different config

It will load config.{NODE_ENV}.js. Create config/config.dev.js file with the following content in workdir:

module.exports = {
  key: "your key",
};
import autoReloadConfig from 'auto-reload-config');
autoReloadConfig.get('key', 'default key');
//your key
NODE_ENV=dev node app.js

##Options

envVar

The name of the environment variable that determines which configuration file to load. Default is NODE_ENV.

envMap

The mapping of environment variables to configuration files. Default doest not map, the suffiex of configuration file uses the value of NODE_ENV.

disableReload

Disable auto reload config file. Default is false.

configDir

The path to the directory where the configuration files are located. Default is {workdir}/config/.

fileType

The file type of the configuration file. Default is js.

Keywords

FAQs

Last updated on 26 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc