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

node-toolbox

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-toolbox

common node utilities for a server app

latest
Source
npmnpm
Version
0.0.1
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

node-toolbox

Functional utilities for node

  • written in ES6
  • requires node 6 and above
  • Simplifies common routines while setting up a node.js application

isDevEnv

  • reads from process.env and assumes some defaults.
  • Ex.
export NODE_ENV=dev;
const {isDevEnv} = require('node-utils')();
isDevEnv(); // {isDev: true, env: 'dev'};
const {isDev} = require('node-utils')();
isDev(); // true
export NODE_ENV=prod;
const {isDevEnv, isDev} = require('node-utils')();
isDev(); // false
isDevEnv(); // {isDev: false, env: 'prod'};

loadConfig

  • sync - loads a config file from your project directory.
const {loadConfig} = require('node-utils')();
loadConfig();

defaults to:

Project
│
└─── config
     │
     └─── config-dev (.js|.json)

load from an environment variable

export NODE_ENV=qa

loads from:

Project
│
└─── config
     │
     └─── config-qa (.js|.json)

You can optionally specify additional arguments such as directory path, directory name and file name:

loadConfig(__dirname, 'test', 'test-config');

file loads from:

Project
│
└─── src
     │
     └─── test
          │
          └─── test-config (.js | .json)
  • Note that if you don't specify an extension name the function will default to a .json file format.
  • You can require the module in one of two flavours
    const {loadConfig} = require('node-utils')()
    
    or
    const {loadConfig} = require('node-utils')(__dirname);
    
    The former allows you to specify a path individually per function call or bind a path to all subsequent calls.

Keywords

node

FAQs

Package last updated on 28 Nov 2016

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