New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@technician/env-config-source

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@technician/env-config-source

Access config from environment variables with Technician.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@technician/env-config-source

npm version npm downloads npm license

dependencies Build Status GitKraken

A config source for accessing environment variables.

This package provides the EnvConfigSource for use with the Technician config manager.

Technician

Installation

npm i @technician/env-config-source

This package is compatible with Node 10 LTS and up.

Usage Examples

The Basics

import {Technician, DefaultInterpreters} from 'technician';
import {EnvConfigSource} from '@technician/env-config-source'

const technician = new Technician(DefaultInterpreters.asText('utf8'));
technician.addSource(new EnvConfigSource());

await technician.read('MY_ENV_VAR');

Overriding Another Source With Environment Variables

import {Technician, DefaultInterpreters} from 'technician';
import {EnvConfigSource} from '@technician/env-config-source';
import {FSConfigSource} from '@technician/fs-config-source';

const technician = new Technician(DefaultInterperters.asBuffer(), {
    // Higher priority sources are checked, even if a value is cached.
    cacheRespectsPriority: true,
    // Set a default cache length. By default, the cache lasts forever.
    defaultCacheLength: 1000 * 60 * 60;
});
const envSource = new EnvConfigSource();
const filesystemSource = new FSConfigSource('/etc/ssl/certs');

// Sources with higher priority will be used over those with lower priority.
// By default, sources have a priority of 0 and cache forever.
technician.addSource([
    {
        source: envSource,
        priority: 1,
        cacheFor: -1 // Disable caching for envSource
    },
    filesystemSource // Just use the default config for FS.
]);

// Create an alias that links both config sources to a single key.
technician.alias('ssl_cert', ['SSL_CERT', 'mysite.crt']);

// This alias will return the filesystem value and cache it for an hour --
// unless SSL_CERT is set, which overrides it and disables caching.
const value = await technician.read('ssl_cert');

Contributions

Contributions and pull requests are always welcome. Please be sure your code passes all existing tests and linting.

Pull requests with full code coverage are strongly encouraged.

License

Apache-2.0

Keywords

FAQs

Package last updated on 30 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc