New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

rf-config

Package Overview
Dependencies
Maintainers
7
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rf-config

NodeJS config loader. Reads a config.js, package.json, LICENSE and .env

latest
Source
npmnpm
Version
1.1.0
Version published
Weekly downloads
67
139.29%
Maintainers
7
Weekly downloads
 
Created
Source

rf-config

NodeJS config loader. Reads a config.js, package.json, LICENSE, .env and CHANGELOG.md.

Getting Started

npm install rf-config

To load this config.js file in ./config/config.js:

module.exports = {

   // we can have any content here
   config: 'local',
   abc: 'def',

   // "paths" is predefined to store all projects paths
   paths: {
      myReadme: 'README.md', // /README.md in root folder
      gitignore: '.gitignore',
      webserver: 'dest',
      server: 'server',
   }
};

Use this single line:

var config = require('rf-config').init(__dirname); // root path '__dirname'

console.log(config);
// this returns a configuration like:

{

   config: 'local',   // variables
   abc: 'def',

   paths: {          // the paths in absolute form for easy backend use
      myReadme: '/home/user/project/README.md',
      gitignore: '/home/user/project/.gitignore',
      webserver: '/home/user/project/dest',
      server: '/home/user/project/server',
   },

   pathsRelative: {  // the paths also relative
      myReadme: 'README.md',
      gitignore: '.gitignore',
      webserver: 'dest',
      server: 'server',
   },

   app: {            // other infos we got for the app
      name: 'rf-config',
      version: '0.1.6',
      packageJson: {
         name: 'rf-config',
         version: '0.1.6',
         description: 'Simple NodeJS config loading lib',
         author: 'Rapidfacture GmbH',
         license: 'MIT',
         main: 'index.js'
      }
   }
}

Once Loaded, access the configuration later in other files with:

var config = require('rf-config');

NOTE: The init function is only present the first time, as the config should be loaded only once - when the project starts.

Development

Install the dev tools with

npm install

Then you can runs some test cases and eslint with:

npm test

  • Licenese: MIT
  • Author: Felix Furtmayr, Julian von Mendel

FAQs

Package last updated on 06 Feb 2022

Did you know?

Socket

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