Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@scaleleap/config

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@scaleleap/config

Extendable configuration base class for 12 Factor application.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@scaleleap/config

Extendable configuration base class for 12 Factor application.

Install

npm i @scaleleap/config

Usage

// in ./src/config.ts

import { BaseConfig } from '@scaleleap/config'

class Config extends BaseConfig {
  public readonly TEST = this.get('TEST').asString()
}
// in ./src/app.ts

const config = new Config()

console.log(config.TEST)

Documentation

Parent Config class exposes a single protected method get, which maps to env-var#get method.

The constructor accepts a single argument, which is an dictionary of key-value strings, that represents the environment. The value defaults to process.env.

This is useful, when you'd like to override the values for testing:

const config = new Config({ NODE_ENV: '...' })

This module will automatically read .env file contents from $PWD/.env.

You can influence the discovery path of .env file via DOTENV_CONFIG_PATH environment variable.

E.g.

DOTENV_CONFIG_PATH=.env.prod node foo.js

Guidelines

  • Property names should match the environment variable name, including case. E.g. NODE_ENV.
  • Properties should be always marked as readonly.
  • Use strict methods where possible, e.g. use asBoolStrict not asBool.

License

MIT © Scale Leap

Keywords

FAQs

Package last updated on 13 Sep 2019

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