Code Monkey home page Code Monkey logo

files.env's Introduction


files.env

npm Version Types

Powered by Enormous

About

Modern package for managing environment variables Files with extension ".env", zero-dependency in the package and easily you can access data in process.env and you can modify and read the data for more details you can read below the method of registering and deleting variables

Table of Contents

Features

  • It allows you to read and write .env files easily and quickly!
  • It does not affect the system values in process.env but you can turn it off if you want but by default it is enabled
  • You can use the package with just a command, without the need to import, which makes the situation easier for you! But you can also import node -r files.env/config index.js
  • Supports writing comments in the file by placing # before the comment line
  • Zero-dependency in the package
  • Allows you to write in the form of an object or add a variable and delete a variable

Installing

Install with npm / yarn / pnpm:

npm install files.env
yarn add files.env
pnpm add files.env

Usage

  • The first step is to create an .env file and put your data in it or use the package to put the data

Configuration

require("files.env").config()
process.env //FileEnv class will be returned to you
import { config} from 'files.env';
config()
process.env//FileEnv class will be returned to you
import { FileEnv } from 'files.env';
const env = new FileEnv()
env//FileEnv class will be returned to you

⚠️ Note in the event that you were a TypeScript Why shouldn't you use the config function and instead use the class?? You must know that process.env has an interface and this interface we cannot modify, so you cannot make the methods available through process.env so if you do a config only you will be able to read so you must use the FileEnv class so that you can read and write

Preload

  • If you do this, you do not need to write a callback, the package will be called in advance
$ node -r files.env/config index.js

Example

Example of class FileEnv

// Read variable from file
process.env.set("name","Mohamed Abdelkarim")//Add a variable in the env . file

//Read variables in the file
console.log(process.env.name)// return "Mohamed Abdelkarim"
//or console.log(process.env.get("name"))

//Delete variable from file
process.env.delete("name")

//Check if a variable exists in the file
console.log(process.env.has("name")) 

//To write an object to the file
process.env.writeFile({token:"11",prefix:"#"})

//Delete all variables from the file
process.env.clear()

//Delete and destroy the file
process.env.destroy()

//If you have modified the file and it is running, you can make the package re-read the variables in the file through this method 
process.env.reloadVariables()//Only in the event that you have modified the file and not from methods or if you want to re-make the package to re-read the file!

Parse and stringify

import { parse, stringify } from 'files.env';
console.log(parse('name="Mohamed"')) // return {"name":"Mohamed"}

console.log(stringify({name:"Mohamed"})) // return name="Mohamed"

File structure

  • Structure example
# Registration information
Name="Mohamed Abdelkarim"
UUID="3cae8d3c-5219-11ed-bdc3-0242ac120002"

# API 
Token="12"# your token!

Documentation

You can see the Documentation of the st.db package to know all the details

Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official Discord Server .

files.env's People

Contributors

shuruhatik avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.