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

cascadia

v0.1.0

Published

oppinionated cascading static config loader

Downloads

2

Readme

Cascadia

Cascadia is an opinionated cascading static configuration loader. It loads static configuration files such that common configuration files are loaded first, followed by a set of environment configuration files which are then optionally followed by a set of machine specific local configurations files.

Conventions

Each configuration file is simply a CommonJS module of a statically defined JSON object (module.exports = {}). Cascadia doesn't attempt to perform any clever object merging. If you have a config parameter in common and you override it with an environment specific config the entire value of the latter config will override the entire value of the prior config.

Cascadia expects the configuration directory it's reading to be laid out in a very specific way. I would make a joke about convention over configuration in a configuration loader here, but all jokes seem to elude me at the moment. In either case, the bare minimum directory structure cascadia expects is as follows.

/configs
  \_ /common
  \_ /local

However, typically you'll want to have environment specific configurations. Cascadia doesn't impose any specific environments on you and it's up to you to define your own environments in the directory structure and tell cascadia which one to use. So say you had dev, stage and prod environments, you're cascadia configuration folder may look like the following

/configs
  \_ /common
  \_ /dev
  \_ /stage
  \_ /prod
  \_ /local

cascadia(location, env = false, local = true)

This module only exports a single function cascadia(). This function takes a required location argument with optional env and local arguments. The location argument is a path to the base configuration folder. The env argument specifies the set of environment configurations to load that should corespond to the name of the folder within the base configuration folder where the environment configurations can be found. If env is false then no environment variables will be loaded. The local variable is just a toggle to enable or disable the loading of local configuration files found in the local folder

  • @param {string} location - The path to the base configuration folder
  • @param {string|boolean} env - The optional environment to load or false
  • @param {boolean} local - The toggle to load local configs
  • @returns {object} - The resulting configuation