mirror of
https://github.com/alexgo-io/xverse-stacks-transaction-sponsor.git
synced 2026-01-12 22:43:48 +08:00
37 lines
806 B
TypeScript
37 lines
806 B
TypeScript
import * as dotenv from "dotenv";
|
|
|
|
let result;
|
|
if (process.env.NODE_ENV === "production") {
|
|
result = dotenv.config({ path: "/usr/src/app/env-config/env" });
|
|
} else {
|
|
result = dotenv.config();
|
|
}
|
|
if (result.error) {
|
|
throw result.error;
|
|
}
|
|
|
|
//will check and return envVar if required env variable is present in .env file
|
|
function isEnvVarValid(envVar: string) {
|
|
if (envVar === undefined || null) {
|
|
throw new Error(
|
|
"Incorrect env variable format! Compare with .env.example."
|
|
);
|
|
}
|
|
return envVar;
|
|
}
|
|
|
|
export default {
|
|
seed: isEnvVarValid(
|
|
process.env.SEED as string
|
|
),
|
|
password: isEnvVarValid(
|
|
process.env.PASSWORD as string
|
|
),
|
|
numAddresses: isEnvVarValid(
|
|
process.env.NUM_ADDRESSES as string
|
|
),
|
|
maxFee: isEnvVarValid(
|
|
process.env.MAX_FEE as string
|
|
),
|
|
};
|