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

jsconf

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

jsconf

Load config from a javascript object

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

jsconf

Load config from a javascript object.

When JSON is too limiting; you need to dynamically set values, include comments or external files in your configuration, jsconf is the tool for you.

installation

npm i jsconf --save

usage

load from a file

var jsconf = require('jsconf')
var config = jsconf.load('/path/to/config.jsconf')
console.log(config)

parse a string

var config = jsconf.parse('{x: +new Date}')
console.log(config)

load from a file with exposed variables

var jsconf = require('jsconf')

// The jsconf object will now have access the variable `cwd`
jsconf.context.cwd = process.cwd()

var config = jsconf.load('/path/to/config.jsconf')
console.log(config)

JSON - N = JSO

A jsconf file contains a single javascript object declaration. There cannot be any executable code outside the object. Comments are allowed anywhere.

These are the perks:

  • Dynamic Properties

    {
    		created: +new Date,
    		nuance:  ~~(100 + (Math.random() * 1000)),
    		guid: (function(x){return x % 200})(+new Date) // closure FTW!
    }
    
  • C-style Comments

    /**
    * Database Configuration
    * blah blah blah
    */
    {
      	mysql: {
      		host: '127.0.0.1',
      		port: 3306,
      		user: 'DB_USER',
      		password: 'DB_PASS',
      		database: 'DB_NAME',
      		//socketPath: '/opt/local/var/run/mysql55/mysqld.sock',
      		// Settings
      		connectionLimit: 10, // Max number of connections to create at once
      		multipleStatements: true, // Allow multiple mysql statements per query
      	},
    }
    
  • Include External Files

    {
      	https: {
      		port: 443,
      		creds: {
      			'key': fs.readFileSync('./app/config/ssl-certs/server.key'),
      			'cert': fs.readFileSync('./app/config/ssl-certs/server.crt'),
      			'ca': fs.readFileSync('./app/config/ssl-certs/ca.crt'),
      			'requestCert': true,
      			'rejectUnauthorized': false
      		}
      	},
    }
    

License

The MIT License

Keywords

FAQs

Package last updated on 07 Aug 2015

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