0.0.1 • Published 2 months ago

config-environment v0.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
2 months ago

Config Environment 🌐🛠️ |  Typescript 

Get your environment variables from a .env file in Node 20, without dependencies, and with type checking

Prerequisites 📋

Make sure you have the following programs installed before getting started:

Installation 🛠️

  1. Install Dependency
npm i config-environment

Usage 🚀

!IMPORTANT For deployment on Node.js version 20 without any dependencies, it is crucial to initiate the application with the following command, incorporating the --env-file flag to ensure environment variables are correctly loaded:

node --env-file=.env index.js

If you are utilizing Bun as your JavaScript runtime, the process is streamlined. Simply execute:

bun index.js

Code Example 🐼

import { ConfigEnvironment } from 'config-environment'

const envs = {
  TEST_PORT: ConfigEnvironment.get( 'TEST_PORT' ).isPort().asNumber(),
  TEST_STRING: ConfigEnvironment.get( 'TEST_STRING' ).asString(),
  TEST_NUMBER: ConfigEnvironment.get( 'TEST_NUMBER' ).asNumber(),
  TEST_BOOL: ConfigEnvironment.get( 'TEST_BOOL' ).asBool(),
  TEST_REQUIRED: ConfigEnvironment.get( 'TEST_REQUIRED' ).isRequired().asString(),
  TEST_GET: ConfigEnvironment.get( 'TEST_GET' ).getValue()
}

Technologies Used 🛠️

License 📄

This project is under the MIT License. Check the LICENSE file for more details. 📜