Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@augu/dotenv
Advanced tools
Readme
:rose: Lightweight and type-safe environment variable parser
const { parse } = require('@augu/dotenv');
parse({
file: '.env', // the current directory gets added if it's just `.env`
populate: false, // If we should return the values or populate "process.env"
readers: [], // Classes of all the custom type readers to use
schema: {
// Define a custom schema (if wanted)
}
});
This library supports adding custom type readers to add more type-safety and validation when parsing. To create one, just make a file myReader.js
(or any file name you want) and put in the following code:
Please note that Type Readers are only supported in the Schema options (
options.schema
), it'll just return as a String if you don't use a proper schema for validation.
const { TypeReader } = require('@augu/dotenv');
module.exports = class MyTypeReader extends TypeReader {
constructor() {
super('id');
}
validate(value) {
// validate this `value`
}
parse(value) {
// parse this `value`
}
};
then you add it to the parse
function like so:
const MyTypeReader = require('./path/to/reader');
const { parse } = require('@augu/dotenv');
parse({
file: '.env',
readers: [MyTypeReader],
schema: {
VALUE: {
type: 'id' // replace 'id' with your type reader's exact ID
}
}
});
This library supports a way to comment .env files without being parsed! All you need to do is add a #
at the start of the pairing and this library will skip it!
.env
# A=B
C=D
index.js
const parse = require('@augu/dotenv');
const result = parse({
file: '.env', // the current directory gets added if it's just `.env`
populate: false, // If we should return the values or populate "process.env"
readers: [], // Classes of all the custom type readers to use
schema: {
// Define a custom schema (if wanted)
}
});
console.log(result); // { c: 'D' }
Yes and no. I made this library to show that I wanted to use this for a long time moving from JSON, so I added Array support due to it not being supported in dotenv. If you don't use the Array support that this library adds, then you are following it.
TL;DR - I don't follow spec rules, I like to add my own twists to the libraries I push out.
It's just, sometimes you get too lazy to do something like:
const idk = process.env.SOMETHING_ARRAY;
idk?.split(', '); // optional chaining is only allowed in Node v14
because you would have to see if SOMETHING_ARRAY
exists and I don't want to do it myself.
I mean, Schemas aren't apart of the .env spec but it's something to validate the file if you don't want the hassle to do if (typeof process.env.IS_THIS_SOMETHING === 'string')
and other stuff, it's just convinent out of the box.
@augu/dotenv is released under the MIT License. Read here for more information.
FAQs
🌹 Lightweight and type-safe environment variable parser
The npm package @augu/dotenv receives a total of 7 weekly downloads. As such, @augu/dotenv popularity was classified as not popular.
We found that @augu/dotenv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.