<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: SiegfredRodriguez</title>
    <description>The latest articles on DEV Community by SiegfredRodriguez (@siegfredrodriguez).</description>
    <link>https://dev.to/siegfredrodriguez</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F699184%2F8389ba66-49ef-401b-a123-a8ed3a7adb58.jpeg</url>
      <title>DEV Community: SiegfredRodriguez</title>
      <link>https://dev.to/siegfredrodriguez</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/siegfredrodriguez"/>
    <language>en</language>
    <item>
      <title>A simple yet handy configuration compositor and locator!</title>
      <dc:creator>SiegfredRodriguez</dc:creator>
      <pubDate>Sat, 04 Sep 2021 15:43:24 +0000</pubDate>
      <link>https://dev.to/siegfredrodriguez/a-simple-yet-handy-configuration-compositor-and-locator-2pa9</link>
      <guid>https://dev.to/siegfredrodriguez/a-simple-yet-handy-configuration-compositor-and-locator-2pa9</guid>
      <description>&lt;p&gt;I finally dipped my toes in opensource, with my simple unopinionated yet capable configuration utility config-discovery!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will not force you on any conventions such as directory and specific files.&lt;/li&gt;
&lt;li&gt;Uses fluent interface, no strange incantations.&lt;/li&gt;
&lt;li&gt;Fit for containerized deployments where configurations maybe split between ConfigMaps and Secrets.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/SiegfredRodriguez/config-discovery"&gt;Github&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.npmjs.com/package/config-discovery"&gt;NPMJS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Some of its features include the ability to define a source priority for your configuration, including environment and directly from an object!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let Config = require('config-discovery');

....

let configuration = new Config()
    .fromFile('/configs/config.json')
    .orFile('/configuration/config.json')
    .orFile('/etc/my_configs/config.json')
    .orEnv(prototype)
    .orObj(configObject)
    .get();

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compose a configuration from multiple sources, including the environment!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let prototype = {user: 'DB_USERNAME', password: 'DB_PASSWORD'}

let configuration = new Config()
    .fromFile('/configs/config.json')
    .orFile('/configuration/config.json')
    .orFile('/etc/my_configs/config.json')
    .thenPatchWith()
    .env(prototype)
    .get();

// or from another file

let configuration = new Config()
    .fromFile('/configs/config.json')
    .orFile('/configuration/config.json')
    .orFile('/etc/my_configs/config.json')
    .thenPatchWith()
    .configFile(/etc/secrets/credentials.json)
    .get();

// or from another object

let configuration = new Config()
    .fromFile('/configs/config.json')
    .orFile('/configuration/config.json')
    .orFile('/etc/my_configs/config.json')
    .thenPatchWith()
    .object(secretsJson)
    .get();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>node</category>
      <category>kubernetes</category>
      <category>microservices</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
