npm.io
1.1.3 • Published 1 year ago

tej-env

Licence
ISC
Version
1.1.3
Deps
0
Size
7 kB
Vulns
0
Weekly
0
Stars
1

Tej-Env

A zero-dependency module to load environment variables in your Nodejs project.

Features

  • Load environment variables and access them anywhere with process.env or our global variable TejEnv
  • Ability to set environment variables to access them anytime anywhere within that application session. (This doesn't update .env file)
  • [UPCOMING] - Optionally update .env file on the go with in-built routes for express.js and te.js

Install

npm install tej-env

Basic Usage

import "tej-env"

// To read an environment variable anywhere in your project:
const value = process.env.YOUR_VARIABLE_NAME;

Advanced Usage

tej-env module can be used to set and unset variables at global level. This will not update the .env file yet. Updating env file is a work in progress.
Import required functions from tej-env module and use them as shown below:

import { env, setEnv, unsetEnv} from 'tej-env'

There are 2 options to read an environment variable or global variable anywhere in your project:

Option 1: Using process.env

const value = process.env.YOUR_VARIABLE_NAME;

Option 2: Using env() function from tej-env

const data = env("YOUR_VARIABLE_NAME");

To set an environment variable or global variable anywhere in your project, use setEnv() function from tej-env
setEnv(key, value);

To unset an environment variable or global variable anywhere in your project, use unsetEnv() function from tej-env
unsetEnv(key, value);

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.


Support

A simple star to this project repo is enough to keep me motivated on this project for days. If you find your self very much excited with this project let me know with a star.


Author

Hirak Chhatbar

➤ License

Distributed under the MIT License. See LICENSE for more information.

Keywords