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

sn-props

v1.0.1

Published

Read properties from multiple URIs provided on the command line.

Downloads

4

Readme

sn-props

Read Application Properties from local files or http resources (formerly node-props)

This package lets application users specify one or more URLs to JSON files containing "application properties." After the files are read and deserialized, a programmer supplied callback is executed. The module provides a read() function which reads the command line arguments looking for the string '--config'. The parameter following the config file is a file:, http: or https: URI.

You can use multiple --config flags to specify multiple resources. Each resource will be read in order and combined into a single object that is passed to the callback.

I use this feature to separate hardware specific properties from application specific properties. I usually have hardware specific properties (like IP addresses and ports to listen on) in files on the filesystem while application specific properties (names of DB servers, application timeouts, etc.) in http resources on our internal net. This is useful if you're running the same application on several different machines.

Installation

The easiest way to install this package is to use npm:

If you want to check out the source, use the git command:

Usage (for end users)

This package is intended to allow a node application user to do something like this:

and then have the system will pull properties from both the local file and the remote server (example.com), munge them together in the same object and start the main body of the application.

The sn-props module will also scan the command line for other parameters (identified by a leading "--".) Values following the parameter will be passed to the props.read() call in the properties object. For instance:

will pass the following object to the program through the props.read() call:

Placing a slash ("/") in a property name will cause that property name to be interpreted as a path into the properties object passwd with the props.read() call. The following invocation:

will pass the following object to the program through the props.read() call:

Usage (for developers)

To use the module, simply import the package can call the read() function. Ex:

The module uses "reasonable" defaults for http and https connections, but these can be overridden by passing options to a new props object and calling the read() function on it directly. For instance, the 'global' option defines a global options file that is read after resources specified on the command line. This code fragment reads properties from files or URLs specified in the command line and then reads them from the file "/etc/sample.json".

License

This package is released under a MIT license, the text of which may be found at https://github.com/smithee-us/sn-props/raw/master/LICENSE .