npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

config_okay

v1.0.1

Published

Make sure config files are mode 0600 before you use it

Downloads

5

Readme

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.

Installation

npm install config_okay

Example

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

config_okay(configfile,function(err,config){
     if(err){
        throw new Error('node.js needs a good croak module')
     }
     do_something(config)
})

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

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

Look at the test file to see what I mean.