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

env-plus

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-plus

Modern package to manage and document evnironment variables with schemas

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-50%
Maintainers
1
Weekly downloads
 
Created
Source

env-plus

This is work in progress. Api changes frequently

Getting started

Run your favourite package manager

npm install env-plus
# yarn add env-plus
# pnpm install env-plus

Make sure you have these properties in typescript config

"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false

Create .env file with example variables

MESSAGE="hello there"
PORT="3000"
LOGGER="true"

Create your first env schema

import * as dotenv from 'dotenv'
dotenv.config()

import { EnvSchema, EnvProperty, EnvManager } from 'env-plus'

@EnvSchema()
export class MyEnvSchema {
  @EnvProperty('MESSAGE')
  message: string

  @EnvProperty('PORT')
  port: number

  @EnvProperty('LOGGER')
  logger: boolean
}

const env = EnvManager.getPlainInstance(MyEnvSchema)

console.log(env)

Returns an object with parsed values

{
  message: 'hello there',
  port: 3000,
  logger: true
}

Keywords

FAQs

Package last updated on 09 Mar 2023

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