BlackAsLight/tinyenv

A tiny dotenv module

★ 0Forks 0TypeScriptGitHub ↗Compare

Project website ↗

denodotenv

README

tinyenv

A module to easily read a .env file located at root and add it to your Deno.env. All keys will be read and recorded as capital letters. So potato is the same as POTATO, and it's also the same as pOtAtO.

Usage

.env

potato=5

main.ts

import 'https://deno.land/x/[email protected]/mod.ts';

console.log(Deno.env.get('POTATO'));

Make sure certain variables exist before proceeding. required will throw an error listing all the missing variables.

import { required } from 'https://deno.land/x/[email protected]/mod.ts';

required(['potato']);

Set up defaults for any variables not currently existing.

import { defaults } from 'https://deno.land/x/[email protected]/mod.ts';

defaults({ potato: '5' });

If you import required or defaults then you don't need to import the module by itself import 'https://deno.land/x/[email protected]/mod.ts'. It will still load all the content in .env just the same.

Contributors

BlackAsLight

Issues