Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including config_okay with all npm packages installed. Try it out:

var configOkay = require("config_okay")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

config_okay v1.0.1

Make sure config files are mode 0600 before you use it

config okay

Build Status

Greenkeeper badge

Code Climate

This became a module because I used it more than once.

It is really simple. All it does is parse a config file. Borrowing from postgresql, it refuses to do anything if the config file isn't chmod 0600. I don't even know what that means in the Windows or Mac world, so patches welcome. Essentially, if a file is not set such that only the owner can read and write it, then it isn't a good idea to store passwords in it.

So, if you have a config file of any sort, and it is set to be chmod 0600, then you can use this file.

What is does is check the permissions of the file, then it requires it and returns the results of the require statement.

According to the node.js docs, require will pull in either a javascript file, or a JSON file.


npm install config_okay


The older version you would do this:

var config_okay = require('config_okay')
var configfile = 'config.json' // or pull from the command line or something

        throw new Error('node.js needs a good croak module')

Now that isn't true anymore because as of May 2017 I've switched to using promises.

So now the usage is

const config_okay = require('config_okay')
const configfile = 'config.json' // or pull from the command line or something

.then(config => {
     return do_something(config)
.catch( e => {
     return handleError(e)

Look at the test file to see what I mean.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free