-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
65 lines (63 loc) · 1.77 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* SPDX-FileCopyrightText: 2021-present Kriasoft */
/* SPDX-License-Identifier: MIT */
export type SecretSource = "google" | "aws" | "azure";
/**
* Loads environment variables from `.env` files. If any of these variables
* reference secret values, they will be fetched from the cloud provider
* such as Google Cloud Secret Manager, AWS Secrets Manager, or Azure Key Vault.
*
* @see https://cloud.google.com/secret-manager
* @example
* const [env, secrets] = await loadEnv("development", {
* root: "..",
* schema: "./core/env.ts",
* mergeTo: process.env,
* });
*
* @param environment Environment name such as "development" or "production".
* @param options Loading options
*/
export function loadEnv(
environment: string | undefined,
options: {
/**
* Where to look for `.env` files. Defaults to the current working directory.
*/
root?: string;
/**
* Lookup filenames.
* @default
* [
* ".env.{environment}.local",
* ".env.{environment}",
* ".env.local",
* ".env"
* ]
*/
files?: string[] | string;
/**
* Path to the environment schema file exporting environment variables
* required by the app at runtime.
*
* @example
* // env.ts
* import { cleanEnv, str, num } from "envalid";
*
* export default cleanEnv(process.env, {
* HOSTNAME: str({ default: "localhost" }),
* PORT: num({ default: 8080 }),
* DB_PASSWORD: str(),
* });
*/
schema?: string;
/**
* Merge the loaded environment variables into the specified object.
*/
mergeTo?: Record<string, unknown>;
},
): Promise<
[
env: Record<string, string>,
secrets: Map<string, { ref: string; source: SecretSource }>,
]
>;