UNPKG

461 BPlain TextView Raw
1import { config, parse } from "dotenv";
2
3const env = config();
4const dbUrl: string | null =
5 env.error || !env.parsed ? null : env.parsed["BASIC"];
6
7config({
8 path: ".env-example",
9 encoding: "utf8",
10 debug: true
11});
12
13const parsed = parse("NODE_ENV=production\nDB_HOST=a.b.c");
14const dbHost: string = parsed["DB_HOST"];
15
16const parsedFromBuffer = parse(new Buffer("JUSTICE=league\n"), {
17 debug: true
18});
19const justice: string = parsedFromBuffer["JUSTICE"];