source: node_modules/dotenv/lib/main.d.ts@ 2d1ec46

main
Last change on this file since 2d1ec46 was 81bc7da, checked in by Klimentina Efremova <klimentina08642@…>, 3 months ago

Initial commit

  • Property mode set to 100644
File size: 5.0 KB
Line 
1// TypeScript Version: 3.0
2/// <reference types="node" />
3import type { URL } from 'url';
4
5export interface DotenvParseOutput {
6 [name: string]: string;
7}
8
9/**
10 * Parses a string or buffer in the .env file format into an object.
11 *
12 * See https://dotenvx.com/docs
13 *
14 * @param src - contents to be parsed. example: `'DB_HOST=localhost'`
15 * @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
16 */
17export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
18 src: string | Buffer
19): T;
20
21export interface DotenvConfigOptions {
22 /**
23 * Default: `path.resolve(process.cwd(), '.env')`
24 *
25 * Specify a custom path if your file containing environment variables is located elsewhere.
26 * Can also be an array of strings, specifying multiple paths.
27 *
28 * example: `require('dotenv').config({ path: '/custom/path/to/.env' })`
29 * example: `require('dotenv').config({ path: ['/path/to/first.env', '/path/to/second.env'] })`
30 */
31 path?: string | string[] | URL;
32
33 /**
34 * Default: `utf8`
35 *
36 * Specify the encoding of your file containing environment variables.
37 *
38 * example: `require('dotenv').config({ encoding: 'latin1' })`
39 */
40 encoding?: string;
41
42 /**
43 * Default: `false`
44 *
45 * Suppress all output (except errors).
46 *
47 * example: `require('dotenv').config({ quiet: true })`
48 */
49 quiet?: boolean;
50
51 /**
52 * Default: `false`
53 *
54 * Turn on logging to help debug why certain keys or values are not being set as you expect.
55 *
56 * example: `require('dotenv').config({ debug: process.env.DEBUG })`
57 */
58 debug?: boolean;
59
60 /**
61 * Default: `false`
62 *
63 * Override any environment variables that have already been set on your machine with values from your .env file.
64 *
65 * example: `require('dotenv').config({ override: true })`
66 */
67 override?: boolean;
68
69 /**
70 * Default: `process.env`
71 *
72 * Specify an object to write your secrets to. Defaults to process.env environment variables.
73 *
74 * example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
75 */
76 processEnv?: DotenvPopulateInput;
77
78 /**
79 * Default: `undefined`
80 *
81 * Pass the DOTENV_KEY directly to config options. Defaults to looking for process.env.DOTENV_KEY environment variable. Note this only applies to decrypting .env.vault files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a .env file.
82 *
83 * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })`
84 */
85 DOTENV_KEY?: string;
86}
87
88export interface DotenvConfigOutput {
89 error?: Error;
90 parsed?: DotenvParseOutput;
91}
92
93export interface DotenvPopulateOptions {
94 /**
95 * Default: `false`
96 *
97 * Turn on logging to help debug why certain keys or values are not being set as you expect.
98 *
99 * example: `require('dotenv').config({ debug: process.env.DEBUG })`
100 */
101 debug?: boolean;
102
103 /**
104 * Default: `false`
105 *
106 * Override any environment variables that have already been set on your machine with values from your .env file.
107 *
108 * example: `require('dotenv').config({ override: true })`
109 */
110 override?: boolean;
111}
112
113export interface DotenvPopulateInput {
114 [name: string]: string;
115}
116
117/**
118 * Loads `.env` file contents into process.env by default. If `DOTENV_KEY` is present, it smartly attempts to load encrypted `.env.vault` file contents into process.env.
119 *
120 * See https://dotenvx.com/docs
121 *
122 * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
123 * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
124 *
125 */
126export function config(options?: DotenvConfigOptions): DotenvConfigOutput;
127
128/**
129 * Loads `.env` file contents into process.env.
130 *
131 * See https://dotenvx.com/docs
132 *
133 * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', quiet: false, debug: true, override: false }`
134 * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
135 *
136 */
137export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput;
138
139/**
140 * Loads `source` json contents into `target` like process.env.
141 *
142 * See https://dotenvx.com/docs
143 *
144 * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object
145 * @param parsed - the source JSON object
146 * @param options - additional options. example: `{ quiet: false, debug: true, override: false }`
147 * @returns {void}
148 *
149 */
150export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions): void;
151
152/**
153 * Decrypt ciphertext
154 *
155 * See https://dotenvx.com/docs
156 *
157 * @param encrypted - the encrypted ciphertext string
158 * @param keyStr - the decryption key string
159 * @returns {string}
160 *
161 */
162export function decrypt(encrypted: string, keyStr: string): string;
Note: See TracBrowser for help on using the repository browser.