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

fi-consts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fi-consts

Static database content manager for Mongoose

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Fi Consts

Simple constant management for your application.

Installing

npm install --save fi-consts

Usage

const CONSTS = require('fi-consts');

Loading

You must first load your constants with a valid config object:

consts CONSTS = require('fi-consts');

CONSTS.load(config);

// CONSTS now has your constants!

Configuration

The configuration Object must have the basedir property defined as a valid path String. The debug parameter is optional.

  • basedir: This is required and must be a String. This must be the absolute path to where the consts are located.
  • debug: This option can be a Function to log with or a Boolean. If true it'll use console.log.
Example configuration
{

  debug = require('debug')('app:statics'),

  basedir: path.join(__dirname, 'consts'),

}

Getting values

Suppose we have this folder structure for the constants:

consts
├── other
│   ├── embedded
│   │   └── values.json
│   └── values.json
└── roles.json

Once loaded, this module will cache all your constants data into memory. To obtain a value just navigate the object. Keep in mind that all constant properties are defined in UPPER_CASE:

console.log(CONSTS.ROLES.USER); // => { VALUE: 'value1234', SLUG: 'ROLE.USER' };
console.log(CONSTS.ROLES.USER.SLUG); // => 'ROLE.USER'
console.log(CONSTS.ROLES.OTHER.EMBEDDED.VALUES); // => { VALUE_1: {...}, VALUE_2: {...}}

Keywords

FAQs

Package last updated on 03 Jan 2017

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