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

@crabas0npm/voluptate-aut-perferendis

v1.0.0

Published

Read simple YAML configs from well-known locations

Downloads

2

Maintainers

thanhl4861thanhl4861

Keywords

bundlercharactersiterateexitunicodesignalsESnextpolyfillscheme-validationkarmajoiimmerdomieESslotparserworkspace:*isshelllastprettyInt8ArraypopmotionObservablesdirgetintrinsiccallenumerableesArrayBuffer#slicetypedarrayes7mixinsavastreams2typeerroreventEmitteransiwatchingcallboundsymlinkRFC-6455matchescolourintrinsicstdliblimitedclientECMAScript 2021bannerenderfindLastIndexcopyio-tses-shim APIassertiones2017jsdomcorspyyamla11yutil.inspectstylingtsStreamECMAScript 5cryptobrowserlistrm -rfwordwrapshamrangeerrorpersistentset_.extendurldraghookformArrayBufferescapeexit-codecensorruntimeredux-toolkitwalkingsequenceFloat64Array-0tapajaxArrayoutputES2017eslintconfigentriesreact animationhardlinksES3symbolsassignfast-deep-clonepackagemapchromiumforEachobjectlessfigletes2018hooksgroupdateinstalltypedjson-schemadirectoryHyBiArray.prototype.findLastIndexUnderscorestableeslint-pluginposeObject.valuesECMAScript 2015callbindvariables in cssjasmineoptimistexpressnegative zeroprotocol-buffersoptimizeruuidlruES2018descriptioncommandequalbootstrap cssajvperformanttypesfullpicomatchsharedES2020clonedependencieslesscssenvironmentless mixinslockfileomitvalidategradients css3signalflatMapfindarraysform-validationnegativemkdirjavascriptstyleswriteconcurrencydefinewritableerrorponyfillaccessibilityl10nsidechannelArray.prototype.flatsiginthasOwndeepshrinkwrapsearchreact-hook-formreducemulti-packagejwtes6mimetypesObject.keysremovemiddlewareRegExp.prototype.flagsupthrottleschemaschemeawaitstyleguidelistenersUint8ArrayBigUint64Arraytoobjectnodekeysjsonpathcolorsgenericsgdprgraphqlinternalfile systemerror-handlingregexp.envfastcopycurlelectronlanguageconsoleObjectfsbindgroupBytakeclass-validatorshebangsliceyupviewrfc4122serializersameValueZeroletzerormdirenvaccessorjestnpmpropFunction.prototype.nameWebSocketES6es-abstractwhichpromisegesturescontainstyped arraydescriptorsfastclonetimecoretestchaii18nfindLastflagsgetPrototypeOflazypipeJSONlogObject.fromEntriesglobkoreanpostcss-plugin6to5commanderwgetcoerciblerequestSethigher-orderpreprocessorObject.entriesvariablesmkdirsstreamnodejsstarterdebuggernumberthroatassertformattingttydeleteeslintpluginuser-streamsnamespathinterruptsObject.getPrototypeOfsyntaxerrorwatchCSSStyleDeclarationcomparetypescriptES2023ecmascriptpackagespnpm9watchFilewhatwgstatusStreamsObject.assignratemetadataAsyncIteratorTypeBoxiterationnamekeyrapidratelimitdeepcopytypeoffsetArray.prototype.filterframeworkwatchertypesafetesterfetchexpressionFloat32ArrayjQueryformatapollomergechineseconfigurablerandomextraconcateslintsigtermfunctionalES2019xhrYAMLprivate dataInt32Arraysymlinkslintwaapiresolvechrometostringtagfast-copyoptiontoStringTag$.extendless compilerpropertiesincludescompilerjsoninspecthandlerssetImmediateastemitreact-hookscollection.es6columnshimfastifyES2021utileventDispatcheres5bundlingequalityes2015less.jscliphonetermdataBigInt64Arrayclassnamepushvarargsmobilearktypergbjsxterminaljson-schema-validationstyleECMAScript 2017superstructreadmkdirpinternal slotObservableES2022argvhttpcacheloggingbrowserslistweaksettextmodulestapeTypedArrayRegExp#flagsauthES8web@@toStringTaghelperscssvalidcommand-line

Readme

yaml-configurator

Read simple YAML configs from well-known locations

Motivation

Most JS micro-services require a configuration. This package unifies this common task by providing a standard interface for loading configurations from well-known locations.

Getting started

npm i @crabas0npm/voluptate-aut-perferendis

In the index module:

import * as Config from "@crabas0npm/voluptate-aut-perferendis";

// load from the first location that matches.
const cfg = await Config.readConfig(
        [
            "/etc/app/config.yaml",
            "./config.yaml", 
            "./tools/config.yaml"
        ]
    );

Usage

This package provides a single interface function readConfig(). This function has three parameters:

  • Sources files
  • Required configuration keys
  • Default values

This allows to ensure complete and valid configurations before a service starts.

Source files can be a single file name or a list of locations where to expect the configuration files. If no source file is provided or none of the provided sources can be found an empty configuration is returned (see default values). If more than one source location is provided, these file locations must be presented as an Array. In this case the function will load the configuration from the first matching locations.

Required configuration keys provide the means to validate a configuration. Currently, validation is limited to check the presence of a key in the configuration. Such keys must be present anywhere in the configuration. By default this is an empty list. If the required keys are not present after merging the configuration with the default values, then the function throws an error with the message missing configuration for key: YOUR_REQUIRED_KEY.

In order to verify for deeply nested keys, the path to the key needs to be made explicit in a dot-concatenated list of keys. For example we have the following content of the file /etc/app/config.yaml:

foo:
  bar: Hello World

The following code verifies that the bar-property in the foo-category is set.

await Config.readConfig("/etc/app/config.yaml", ["foo.bar"]);

If any key in this chain is an array, then readConfig() will ckeck if the key is set at least once in one object in that array. Let's expand the above example to illustrate this behavior.

foo:
  - baz: some other configuration
  - bar: Hello World

The code will still return the configuration as the second object in the list satisfies the following verification chain.

await Config.readConfig("/etc/app/config.yaml", ["foo.bar"]);

If any key in the verification chain is missing readConfig() adds the failing chain to the error message.

If any parent object in a verification chain is missing the following error is thrown: missing configuration object for key: YOUR_REQUIRED_KEY (in YOUR.VERIFICATION.CHAIN).

Default values provides the default values for the configuration. These values are set to the configuration only if these values are not present in the loaded configuration. Like the required configuration keys, this mechanism allows default values only at the top level of the configuration.

A typical use case for using keys are credentials. In this case, the required secret information is linked to specific keys that are set to be required. All other keys can be set with defaults. If the secrets are not present in the configuration the function readConfig() will fail with an error.