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

darc-mongoreadyserverconfig

v0.1.4

Published

A generic "MongoDB ready" server configuration module, built to handle ENV, configuration file, and command line argument values

Downloads

7

Readme

Introduction

Package to handle flexible configuration for the darc-mongoreadyserver package. Our intention is that it should be easy to run a server, from the command line, based on this package.

You can specify environment variables, either with export or with a .env file in your project's root directory. All environment variables should be preceeded by your project name, in upper case, with any - characters replaced with _, followed by an _, and then the variable name. For example,

MYPROJECT_CUSTOM_ENV_VAR="Hi!"

This will be read into the configuration object with the key custom-env-var. Of course, the variables can also be the defaults required by the package, as in

MYPROJECT_PORT=6000
MYPROJECT_SSL_CERT=/path/to/sssl/cert
MYPROJECT_SSL_KEY=/path/to/ssl/key

You can specify a configuration file, currently in JSON form. You can set an environment variable MYPROJECT_CONFFILE to point to this file, or you can use the command line argument '--conffile'. Such a configuration file will be read and imported into the configuration directly.

You can also run with long-form command line arguments (run with --help to see which), and you can even specify your own command line arguments (and value checks). Our examples here show how to use command line arguments; to add custom arguments you need to pass arguments optargs and/or checks to the routine returned from the require call:

require( 'darc-monngoreadyserver' )( modules , optargs , checks )
	...

optargs should be an object whose keys are the long-form options to include (minus the -- prefix), and whose corresponding values should be argparse-ready option setting objects. For example,

let optargs = {
	'custom-flag' : { help : 'An extra flag' , action : "storeTrue" , default : false } , 
	'custom-arg' : { help : 'An extra argument' , default : 7 } , 
}

See the argparse docs for more details. checks, if provided, should be an object whose keys are the argument names (e.g., custom-flag) and whose values are strings that can be executed as an eval statement over a single variable val returning a boolean. For example,

let checks = { 
	'custom-arg' : 'val >= 2'
}

These different routes have a specific precedence order: environment variables are overwritten by config file values which are overwritten by command line arguments (to the degree there are any conflicts). The only exception is a config file path itself, which is set to any value from the environment overwritten by any command line argument provided.