Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

make-node-env

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

make-node-env

Make use of json file formatting for handling node environment configs.

  • 0.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm version

NPM

NPM

NPM

make-node-env

Make use of json file formatting for handling node environment configs.

Installation

Using npm:

npm i make-node-env

or

Using yarn:

yarn add make-node-env

Setup

/**
 * Using Sync configuration loading
 */
const syncConfg = path.resolve(__dirname + `/config2.json`);
exports.syncConfig = SyncConfig({ path: syncConfg, debug: true });

/**
 * Using Async configuration loading
 */
const asyncConfg = path.resolve(__dirname + `/config.json`);
exports.asyncConfig = async function () {
    return await AsyncConfig({ path: asyncConfg, debug: true })
};

Usage sample with Jest test

const { syncConfig, asyncConfig } = require('./index.js');

test('Configuration using sync load with config2.json', function () {
  const host = syncConfig.get('api.host');
  expect(host).toMatchObject({
    "url": "https://www.sync.com",
    "port": 9000,
    "hasSSL": true
  })

  const value = syncConfig.get('api.host.hasSSL');
  expect(value).toBe(true);
});

test('Configuration using async load with config.json', function () {
  async function load() {
    const config = await asyncConfig();

    const host = config.get('webURLs.api.host');
    expect(host).toMatchObject({
      "url": "https://www.host.com",
      "port": 9000,
      "hasSSL": true
    })

    const value = config.get('webURLs.api.host.hasSSL');
    expect(value).toBe(true);
  }

  load();
});

Jest Test

Screenshot 2023-05-05 at 8 55 00 PM

Keywords

FAQs

Package last updated on 16 May 2023

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc